@@ -83,6 +83,7 @@ public class ApiClient {
8383 private Consumer <HttpResponse <String >> asyncResponseInterceptor ;
8484 private Duration readTimeout ;
8585 private Duration connectTimeout ;
86+ private HttpClient httpClient ;
8687
8788 private static String valueToString (Object value ) {
8889 if (value == null ) {
@@ -190,6 +191,7 @@ public ApiClient() {
190191 connectTimeout = null ;
191192 responseInterceptor = null ;
192193 asyncResponseInterceptor = null ;
194+ this .httpClient = this .builder .build ();
193195 }
194196
195197 /**
@@ -208,6 +210,7 @@ public ApiClient(HttpClient.Builder builder, ObjectMapper mapper, String baseUri
208210 connectTimeout = null ;
209211 responseInterceptor = null ;
210212 asyncResponseInterceptor = null ;
213+ this .httpClient = this .builder .build ();
211214 }
212215
213216 protected ObjectMapper createDefaultObjectMapper () {
@@ -249,6 +252,7 @@ public void updateBaseUri(String baseUri) {
249252 */
250253 public ApiClient setHttpClientBuilder (HttpClient .Builder builder ) {
251254 this .builder = builder ;
255+ this .httpClient = null ;
252256 return this ;
253257 }
254258
@@ -260,7 +264,10 @@ public ApiClient setHttpClientBuilder(HttpClient.Builder builder) {
260264 * @return The HTTP client.
261265 */
262266 public HttpClient getHttpClient () {
263- return builder .build ();
267+ if (httpClient == null ) {
268+ httpClient = builder .build ();
269+ }
270+ return httpClient ;
264271 }
265272
266273 /**
0 commit comments