Source:
<code>public InfluxDBImpl(final String url, final String username, final String password, final OkHttpClient.Builder okHttpBuilder, final Retrofit.Builder retrofitBuilder, final ResponseFormat responseFormat) { this.messagePack = ResponseFormat.MSGPACK.equals(responseFormat); this.hostAddress = parseHostAddress(url); this.loggingInterceptor = new HttpLoggingInterceptor(); setLogLevel(LOG_LEVEL); this.gzipRequestInterceptor = new GzipRequestInterceptor(); OkHttpClient.Builder clonedBuilder = okHttpBuilder.build().newBuilder(); clonedBuilder.addInterceptor(loggingInterceptor).addInterceptor(gzipRequestInterceptor). addInterceptor(new BasicAuthInterceptor(username, password)); Factory converterFactory = null; switch (responseFormat) { case MSGPACK: clonedBuilder.addInterceptor(chain -> { Request request = chain.request().newBuilder().addHeader("Accept", APPLICATION_MSGPACK).build(); return chain.proceed(request); }); converterFactory = MessagePackConverterFactory.create(); chunkProccesor = new MessagePackChunkProccesor(); break; case JSON: default: converterFactory = MoshiConverterFactory.create(); Moshi moshi = new Moshi.Builder().build(); JsonAdapter<QueryResult> adapter = moshi.adapter(QueryResult.class); chunkProccesor = new JSONChunkProccesor(adapter); break; } <START> this.retrofit = retrofitBuilder.baseUrl(url).client( <END> clonedBuilder.build()).addConverterFactory(converterFactory).build(); this.influxDBService = this.retrofit.create(InfluxDBService.class); }</code><technical_language>a heads up: ConcurrentModificationException adding a converterFactory a shared thread-safe retrofitBuilder. Worst case scenatio if trigger a CME, end multiple converterFactory [added internal list in retrofitBuilder](<LINK_0></technical_language>

Target:
public InfluxDBImpl(final String url, final String username, final String password, final OkHttpClient.Builder okHttpBuilder, final Retrofit.Builder retrofitBuilder, final ResponseFormat responseFormat) { this.messagePack = ResponseFormat.MSGPACK.equals(responseFormat); this.hostAddress = parseHostAddress(url); this.loggingInterceptor = new HttpLoggingInterceptor(); setLogLevel(LOG_LEVEL); this.gzipRequestInterceptor = new GzipRequestInterceptor(); OkHttpClient.Builder clonedOkHttpBuilder = okHttpBuilder.build().newBuilder(); clonedOkHttpBuilder.addInterceptor(loggingInterceptor).addInterceptor(gzipRequestInterceptor). addInterceptor(new BasicAuthInterceptor(username, password)); Factory converterFactory = null; switch (responseFormat) { case MSGPACK: clonedOkHttpBuilder.addInterceptor(chain -> { Request request = chain.request().newBuilder().addHeader("Accept", APPLICATION_MSGPACK).build(); return chain.proceed(request); }); converterFactory = MessagePackConverterFactory.create(); chunkProccesor = new MessagePackChunkProccesor(); break; case JSON: default: converterFactory = MoshiConverterFactory.create(); Moshi moshi = new Moshi.Builder().build(); JsonAdapter<QueryResult> adapter = moshi.adapter(QueryResult.class); chunkProccesor = new JSONChunkProccesor(adapter); break; } Retrofit.Builder clonedRetrofitBuilder = retrofitBuilder.baseUrl(url).build().newBuilder(); this.retrofit = clonedRetrofitBuilder.client(clonedOkHttpBuilder.build()) .addConverterFactory(converterFactory).build(); this.influxDBService = this.retrofit.create(InfluxDBService.class); }