2020import javax .annotation .Nonnull ;
2121import javax .annotation .Nullable ;
2222
23+ import org .apache .hc .client5 .http .classic .HttpClient ;
2324import org .apache .hc .client5 .http .impl .classic .CloseableHttpClient ;
2425import org .apache .hc .client5 .http .protocol .HttpClientContext ;
2526import org .apache .hc .core5 .http .io .HttpClientResponseHandler ;
@@ -80,6 +81,10 @@ public class ApiClient
8081 @ Nonnull
8182 private final UnaryOperator <ClassicRequestBuilder > requestCustomizer ;
8283
84+ private static OpenApiResponseListener EMPTY_RESPONSE_LISTENER = r -> {
85+ };
86+ private static UnaryOperator <ClassicRequestBuilder > EMPTY_REQUEST_CUSTOMIZER = r -> r ;
87+
8388 /**
8489 * Creates an ApiClient instance from an existing HttpClient.
8590 *
@@ -107,8 +112,13 @@ public static ApiClient fromHttpClient( @Nonnull final CloseableHttpClient httpC
107112 ApiClient
108113 fromHttpClient ( @ Nonnull final CloseableHttpClient httpClient , @ Nonnull final String basePath )
109114 {
110- return new ApiClient (httpClient , basePath , createDefaultObjectMapper (), null , r -> {
111- }, r -> r );
115+ return new ApiClient (
116+ httpClient ,
117+ basePath ,
118+ createDefaultObjectMapper (),
119+ null ,
120+ EMPTY_RESPONSE_LISTENER ,
121+ EMPTY_REQUEST_CUSTOMIZER );
112122 }
113123
114124 /**
@@ -121,9 +131,8 @@ public static ApiClient fromHttpClient( @Nonnull final CloseableHttpClient httpC
121131 @ Nonnull
122132 public static ApiClient create ( @ Nonnull final Destination destination )
123133 {
124- final CloseableHttpClient httpClient =
125- (CloseableHttpClient ) ApacheHttpClient5Accessor .getHttpClient (destination );
126- return fromHttpClient (httpClient , destination .asHttp ().getUri ().toString ());
134+ final HttpClient httpClient = ApacheHttpClient5Accessor .getHttpClient (destination );
135+ return fromHttpClient ((CloseableHttpClient ) httpClient , destination .asHttp ().getUri ().toString ());
127136 }
128137
129138 /**
0 commit comments