<commit_before>package io.searchbox.client;

import io.searchbox.client.config.ClientConfig;
import io.searchbox.client.config.ClientConstants;
import io.searchbox.client.http.JestHttpClient;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.FactoryBean;

import java.util.LinkedHashSet;

/**
 * @author <NAME>
 */


public class JestClientFactory implements FactoryBean<JestClient> {

	final static Logger log = LoggerFactory.getLogger(JestClientFactory.class);

    private ClientConfig clientConfig;

    public JestClient getObject() {
        JestHttpClient client = new JestHttpClient();
        HttpClient httpclient;

        if (clientConfig != null) {
            log.debug("Creating HTTP client based on configuration");
            client.setServers((LinkedHashSet) clientConfig.getServerProperty(ClientConstants.SERVER_LIST));
            Boolean isMultiThreaded = (Boolean) clientConfig.getClientFeature(ClientConstants.IS_MULTI_THREADED);
            if (isMultiThreaded) {
                PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
                httpclient = new DefaultHttpClient(cm);
                log.debug("Multi Threaded http client created");
            } else {
                httpclient = new DefaultHttpClient();
                log.debug("Default http client is created without multi threaded option");
            }
            if (clientConfig.getClientFeature(ClientConstants.DEFAULT_INDEX) != null) {
                client.registerDefaultIndex((String) clientConfig.getClientFeature(ClientConstants.DEFAULT_INDEX));
                if (clientConfig.getClientFeature(ClientConstants.DEFAULT_TYPE) != null) {
                    client.registerDefaultType((String) clientConfig.getClientFeature(ClientConstants.DEFAULT_TYPE));
                }<commit_msg>avoid null pointer exception if no thread config is set<commit_after>package io.searchbox.client;

import io.searchbox.client.config.ClientConfig;
import io.searchbox.client.config.ClientConstants;
import io.searchbox.client.http.JestHttpClient;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.FactoryBean;

import java.util.LinkedHashSet;

/**
 * @author <NAME>
 */


public class JestClientFactory implements FactoryBean<JestClient> {

	final static Logger log = LoggerFactory.getLogger(JestClientFactory.class);

    private ClientConfig clientConfig;

    public JestClient getObject() {
        JestHttpClient client = new JestHttpClient();
        HttpClient httpclient;

        if (clientConfig != null) {
            log.debug("Creating HTTP client based on configuration");
            client.setServers((LinkedHashSet) clientConfig.getServerProperty(ClientConstants.SERVER_LIST));
            Boolean isMultiThreaded = (Boolean) clientConfig.getClientFeature(ClientConstants.IS_MULTI_THREADED);
            if (isMultiThreaded != null && isMultiThreaded) {
                PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
                httpclient = new DefaultHttpClient(cm);
                log.debug("Multi Threaded http client created");
            } else {
                httpclient = new DefaultHttpClient();
                log.debug("Default http client is created without multi threaded option");
            }
            if (clientConfig.getClientFeature(ClientConstants.DEFAULT_INDEX) != null) {
                client.registerDefaultIndex((String) clientConfig.getClientFeature(ClientConstants.DEFAULT_INDEX));
                if (clientConfig.getClientFeature(ClientConstants.DEFAULT_TYPE) != null) {
                    client.registerDefaultType((String) clientConfig.getClientFeature(ClientConstants.DEFAULT_TYPE));
                }
{'fraction_non_alphanumeric': 0.08666182522391673, 'fraction_numerical': 0.0009682885499878964, 'mean_word_length': 3.4718614718614718, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6644056', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1017, 'n_words': 207}