Source:
public JestClient getObject() { JestHttpClient client = new JestHttpClient(); if (httpClientConfig == null) { log.debug("There is no configuration to create http client. Going to create simple client with default values"); httpClientConfig = new HttpClientConfig.Builder("http://localhost:9200").build(); } client.setRequestCompressionEnabled(httpClientConfig.isRequestCompressionEnabled()); client.setServers(httpClientConfig.getServerList()); final HttpClientConnectionManager connectionManager = getConnectionManager(); final NHttpClientConnectionManager asyncConnectionManager = getAsyncConnectionManager(); client.setHttpClient(createHttpClient(connectionManager)); client.setAsyncClient(createAsyncHttpClient(asyncConnectionManager)); Gson gson = httpClientConfig.getGson(); if (gson == null) { log.info("Using default GSON instance"); } else { log.info("Using custom GSON instance"); client.setGson(gson); } if (httpClientConfig.isDiscoveryEnabled()) { log.info("Node Discovery enabled..."); if (StringUtils.isNotEmpty(httpClientConfig.getDiscoveryFilter())) { log.info("Node Discovery filtering on \"" + httpClientConfig.getDiscoveryFilter() + "\""); } NodeChecker nodeChecker = createNodeChecker(client, httpClientConfig); client.setNodeChecker(nodeChecker); nodeChecker.startAsync(); nodeChecker.awaitRunning(); } else { log.info("Node Discovery disabled..."); } if (httpClientConfig.getMaxConnectionIdleTime() > 0) { log.info("Idle connection reaping enabled..."); IdleConnectionReaper reaper = new IdleConnectionReaper(httpClientConfig, new HttpReapableConnectionManager(connectionManager, asyncConnectionManager)); client.setIdleConnectionReaper(reaper); reaper.startAsync(); reaper.awaitRunning(); } else { log.info("Idle connection reaping disabled..."); } return client; }

Target:
public JestClient getObject() { JestHttpClient client = new JestHttpClient(); if (httpClientConfig == null) { log.debug("There is no configuration to create http client. Going to create simple client with default values"); httpClientConfig = new HttpClientConfig.Builder("http://localhost:9200").build(); } client.setRequestCompressionEnabled(httpClientConfig.isRequestCompressionEnabled()); client.setServers(httpClientConfig.getServerList()); final HttpClientConnectionManager connectionManager = getConnectionManager(); final NHttpClientConnectionManager asyncConnectionManager = getAsyncConnectionManager(); client.setHttpClient(createHttpClient(connectionManager)); client.setAsyncClient(createAsyncHttpClient(asyncConnectionManager)); Gson gson = httpClientConfig.getGson(); if (gson == null) { log.info("Using default GSON instance"); } else { log.info("Using custom GSON instance"); client.setGson(gson); } if (httpClientConfig.isDiscoveryEnabled()) { log.info("Node Discovery enabled..."); if (StringUtils.isNotEmpty(httpClientConfig.getDiscoveryFilter())) { log.info("Node Discovery filtering nodes on \"{}\"", httpClientConfig.getDiscoveryFilter()); } NodeChecker nodeChecker = createNodeChecker(client, httpClientConfig); client.setNodeChecker(nodeChecker); nodeChecker.startAsync(); nodeChecker.awaitRunning(); } else { log.info("Node Discovery disabled..."); } if (httpClientConfig.getMaxConnectionIdleTime() > 0) { log.info("Idle connection reaping enabled..."); IdleConnectionReaper reaper = new IdleConnectionReaper(httpClientConfig, new HttpReapableConnectionManager(connectionManager, asyncConnectionManager)); client.setIdleConnectionReaper(reaper); reaper.startAsync(); reaper.awaitRunning(); } else { log.info("Idle connection reaping disabled..."); } HttpHost preemptiveAuthTargetHost = httpClientConfig.getPreemptiveAuthTargetHost(); if (preemptiveAuthTargetHost != null) { log.info("Authentication cache set for preemptive authentication"); client.setHttpClientContextTemplate(createPreemptiveAuthContext(preemptiveAuthTargetHost)); } return client; }