Skip to content

Commit 8c3a6b5

Browse files
committed
fix(core): Modify HTTP client on first API call
1 parent ec3abee commit 8c3a6b5

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

core/src/main/java/com/ibm/watson/developer_cloud/http/HttpClientSingleton.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,17 +226,18 @@ public OkHttpClient createHttpClient() {
226226
* Configures the current {@link OkHttpClient} instance based on the passed-in options.
227227
*
228228
* @param options the {@link HttpConfigOptions} object for modifying the client
229+
* @return the client
229230
*/
230-
public void configureClient(HttpConfigOptions options) {
231-
if (options == null) {
232-
return;
231+
public OkHttpClient configureClient(HttpConfigOptions options) {
232+
if (options != null) {
233+
if (options.shouldDisableSslVerification()) {
234+
disableSslVerification();
235+
}
236+
if (options.getProxy() != null) {
237+
setProxy(options.getProxy());
238+
}
233239
}
234240

235-
if (options.shouldDisableSslVerification()) {
236-
disableSslVerification();
237-
}
238-
if (options.getProxy() != null) {
239-
setProxy(options.getProxy());
240-
}
241+
return okHttpClient;
241242
}
242243
}

core/src/main/java/com/ibm/watson/developer_cloud/service/WatsonService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,12 @@ protected OkHttpClient configureHttpClient() {
167167
}
168168

169169
/**
170-
* Configures the inner HTML client based on the passed-in options.
170+
* Configures the {@link OkHttpClient} based on the passed-in options.
171171
*
172172
* @param options the {@link HttpConfigOptions} object for modifying the client
173173
*/
174174
public void configureClient(HttpConfigOptions options) {
175-
HttpClientSingleton.getInstance().configureClient(options);
175+
client = HttpClientSingleton.getInstance().configureClient(options);
176176
}
177177

178178
/**

0 commit comments

Comments
 (0)