<commit_before>package com.pcloud.networking;

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.*;

import static com.pcloud.networking.Util.typesMatch;

public class Cyclone {

    private final static Collection<TypeAdapterFactory> DEFAULT_FACTORIES;

    static {
        DEFAULT_FACTORIES = new ArrayList<>(4);
        DEFAULT_FACTORIES.add(new PrimitiveTypesAdapterFactory());
        DEFAULT_FACTORIES.add(new CollectionsTypeAdapterFactory());
        DEFAULT_FACTORIES.add(new ArrayTypeAdapterFactory());
        DEFAULT_FACTORIES.add(new ClassTypeAdapterFactory());
    }

    public static Builder create() {
        return new Builder();
    }

    private final List<TypeAdapterFactory> adapterFactories;
    private final Map<Type, TypeAdapter<?>> typeToAdapterMap;
    private final ThreadLocal<List<StubTypeAdapter<?>>> pendingAdapterRef;

    private Cyclone(Builder builder) {
        typeToAdapterMap = new LinkedHashMap<>();
        pendingAdapterRef = new ThreadLocal<>();
        adapterFactories = new ArrayList<>();
        adapterFactories.addAll(DEFAULT_FACTORIES);
        adapterFactories.addAll(builder.factories);
    }

    public <T> TypeAdapter<T> getTypeAdapter(Class<T> type) {
        return getTypeAdapter(type);
    }

    public <T> TypeAdapter<T> getTypeAdapter(Type type) {
        type = Types.canonicalize(type);

        // Try to return a cached adapter, if any.
        synchronized (typeToAdapterMap) {
            TypeAdapter<?> result = typeToAdapterMap.get(type);
            if (result != null) {
                return (TypeAdapter<T>) result;
            }<commit_msg>Fix a unwanted recursion in Cyclone.getTypeAdapter()<commit_after>package com.pcloud.networking;

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.*;

import static com.pcloud.networking.Util.typesMatch;

public class Cyclone {

    private final static Collection<TypeAdapterFactory> DEFAULT_FACTORIES;

    static {
        DEFAULT_FACTORIES = new ArrayList<>(4);
        DEFAULT_FACTORIES.add(new PrimitiveTypesAdapterFactory());
        DEFAULT_FACTORIES.add(new CollectionsTypeAdapterFactory());
        DEFAULT_FACTORIES.add(new ArrayTypeAdapterFactory());
        DEFAULT_FACTORIES.add(new ClassTypeAdapterFactory());
    }

    public static Builder create() {
        return new Builder();
    }

    private final List<TypeAdapterFactory> adapterFactories;
    private final Map<Type, TypeAdapter<?>> typeToAdapterMap;
    private final ThreadLocal<List<StubTypeAdapter<?>>> pendingAdapterRef;

    private Cyclone(Builder builder) {
        typeToAdapterMap = new LinkedHashMap<>();
        pendingAdapterRef = new ThreadLocal<>();
        adapterFactories = new ArrayList<>();
        adapterFactories.addAll(DEFAULT_FACTORIES);
        adapterFactories.addAll(builder.factories);
    }

    public <T> TypeAdapter<T> getTypeAdapter(Class<T> type) {
        return getTypeAdapter((Type)type);
    }

    public <T> TypeAdapter<T> getTypeAdapter(Type type) {
        type = Types.canonicalize(type);

        // Try to return a cached adapter, if any.
        synchronized (typeToAdapterMap) {
            TypeAdapter<?> result = typeToAdapterMap.get(type);
            if (result != null) {
                return (TypeAdapter<T>) result;
            }
{'fraction_non_alphanumeric': 0.10026777744718833, 'fraction_numerical': 0.0005950609937518596, 'mean_word_length': 3.3947712418300653, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3138800', 'n_tokens_mistral': 903, 'n_tokens_neox': 892, 'n_words': 201}