@@ -81,7 +81,6 @@ public List<Proxy> select(URI uri) {
8181
8282 private static final String USER_AGENT = ClickHouseClientOption .buildUserAgent (null , "HttpClient" );
8383
84- private final AtomicBoolean busy ;
8584 private final HttpClient httpClient ;
8685 private final HttpRequest pingRequest ;
8786
@@ -197,15 +196,13 @@ protected HttpClientConnectionImpl(ClickHouseNode server, ClickHouseRequest<?> r
197196 builder .sslContext (ClickHouseSslContextProvider .getProvider ().getSslContext (SSLContext .class , config )
198197 .orElse (null ));
199198 }
200-
201- busy = new AtomicBoolean (false );
202199 httpClient = builder .build ();
203200 pingRequest = newRequest (getBaseUrl () + "ping" );
204201 }
205202
206203 @ Override
207204 protected boolean isReusable () {
208- return ! busy . get ();
205+ return true ; // httpClient is stateless and can be reused
209206 }
210207
211208 private CompletableFuture <HttpResponse <InputStream >> postRequest (HttpRequest request ) {
@@ -243,8 +240,6 @@ private ClickHouseHttpResponse postStream(ClickHouseConfig config, HttpRequest.B
243240 }
244241
245242 return buildResponse (config , r , output , postAction );
246- } finally {
247- busy .set (false );
248243 }
249244 }
250245
@@ -267,8 +262,6 @@ private ClickHouseHttpResponse postString(ClickHouseConfig config, HttpRequest.B
267262 }
268263 }
269264 return buildResponse (config , r , output , postAction );
270- } finally {
271- busy .set (false );
272265 }
273266 }
274267
@@ -281,9 +274,7 @@ protected final String getDefaultUserAgent() {
281274 protected ClickHouseHttpResponse post (ClickHouseConfig config , String sql , ClickHouseInputStream data ,
282275 List <ClickHouseExternalTable > tables , ClickHouseOutputStream output , String url ,
283276 Map <String , String > headers , Runnable postAction ) throws IOException {
284- if (!busy .compareAndSet (false , true )) {
285- throw new ConnectException ("Connection is busy" );
286- }
277+
287278 ClickHouseConfig c = config == null ? this .config : config ;
288279 HttpRequest .Builder reqBuilder = HttpRequest .newBuilder ()
289280 .uri (URI .create (ClickHouseChecker .isNullOrEmpty (url ) ? this .url : url ))
0 commit comments