<commit_before>package com.worldline.openxcmanagers.sdk;

import com.worldline.openxcmanagers.sdk.service.OpenXCService;

import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
import retrofit.client.Response;

public class ApiClient {

    private static ApiClient INSTANCE;
    private final ApiClientProvider clientProvider;
    private RestAdapter.LogLevel logLevel;
    private RestAdapter.Log log;

    public static ApiClient init(ApiClientProvider clientProvider) {
        if (clientProvider == null) {
            throw new IllegalArgumentException("ApiClientProvider can not be null");
        }

        if (INSTANCE == null) {
            INSTANCE = new ApiClient(clientProvider);
        }
        return INSTANCE;
    }

    public static ApiClient getInstance() {
        if (INSTANCE == null) {
            throw new IllegalArgumentException("ApiClient should be initialized before call getInstance()");
        }
        return INSTANCE;
    }

    private ApiClient(ApiClientProvider apiClientProvider) {
        clientProvider = apiClientProvider;
    }

    public void getData(Callback<OpenXCResponse> callback) {
        RestAdapter restAdapter = createRestAdapter();
        restAdapter.create(OpenXCService.class).getData(callback);
    }

    public void postData(String key, String value, Callback<Response> callback) {
        RestAdapter restAdapter = createRestAdapter();
        restAdapter.create(OpenXCService.class).postData(key, value, callback);
    }

    public void customMessage(String name, String value, String event, Callback<Response> callback) {
        RestAdapter restAdapter = createRestAdapter();
        restAdapter.create(OpenXCService.class).customMessage(name, value, event, callback);
    }

    private RestAdapter createRestAdapter() {
        RestAdapter.Builder builder = new RestAdapter.Builder();
        builder.setEndpoint(clientProvider);

        if (logLevel != null && log != null) {
            builder.setLogLevel(logLevel);
            builder.setLog(log);
        }

        return builder.build();
    }

    public void setLog(RestAdapter.LogLevel logLevel, RestAdapter.Log log) {
        this.logLevel = logLevel;
        this.log = log;
    }
}
<commit_msg>Fix for weird behavior on set data<commit_after>package com.worldline.openxcmanagers.sdk;

import com.worldline.openxcmanagers.sdk.service.OpenXCService;

import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
import retrofit.client.Response;

public class ApiClient {

    private static ApiClient INSTANCE;
    private final ApiClientProvider clientProvider;
    private RestAdapter.LogLevel logLevel;
    private RestAdapter.Log log;
    private boolean waitForResponse;

    public static ApiClient init(ApiClientProvider clientProvider) {
        if (clientProvider == null) {
            throw new IllegalArgumentException("ApiClientProvider can not be null");
        }

        if (INSTANCE == null) {
            INSTANCE = new ApiClient(clientProvider);
        }
        return INSTANCE;
    }

    public static ApiClient getInstance() {
        if (INSTANCE == null) {
            throw new IllegalArgumentException("ApiClient should be initialized before call getInstance()");
        }
        return INSTANCE;
    }

    private ApiClient(ApiClientProvider apiClientProvider) {
        clientProvider = apiClientProvider;
    }

    public void getData(Callback<OpenXCResponse> callback) {
        if (!waitForResponse) {
            RestAdapter restAdapter = createRestAdapter();
            restAdapter.create(OpenXCService.class).getData(callback);
        }
    }

    public void postData(String key, String value, Callback<Response> callback) {
        waitForResponse = true;
        RestAdapter restAdapter = createRestAdapter();
        restAdapter.create(OpenXCService.class).postData(key, value, new WaitCallback(callback));
    }

    public void customMessage(String name, String value, String event, Callback<Response> callback) {
        waitForResponse = true;
        RestAdapter restAdapter = createRestAdapter();
        restAdapter.create(OpenXCService.class).customMessage(name, value, event, new WaitCallback(callback));
    }

    private RestAdapter createRestAdapter() {
        RestAdapter.Builder builder = new RestAdapter.Builder();
        builder.setEndpoint(clientProvider);

        if (logLevel != null && log != null) {
            builder.setLogLevel(logLevel);
            builder.setLog(log);
        }

        return builder.build();
    }

    public void setLog(RestAdapter.LogLevel logLevel, RestAdapter.Log log) {
        this.logLevel = logLevel;
        this.log = log;
    }

   private class WaitCallback implements Callback<Response> {
       private final Callback<Response> callback;

       public WaitCallback(Callback<Response> callback) {
           this.callback = callback;
       }

       @Override
        public void success(Response response, Response response2) {
            waitForResponse = false;
           if (callback != null) {
               callback.success(response, response2);
           }
        }

        @Override
        public void failure(RetrofitError error) {
            waitForResponse = false;
            if (callback != null) {
                callback.failure(error);
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.0837037037037037, 'fraction_numerical': 0.00037037037037037035, 'mean_word_length': 2.8359375, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '2369782', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1373, 'n_words': 338}