Skip to content

Commit 617dcbb

Browse files
Refactor HttpAPIClientHelper to improve response cleanup handling. Bring back in-place response cleanup
1 parent d5455db commit 617dcbb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

client-v2/src/main/java/com/clickhouse/client/api/internal/HttpAPIClientHelper.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,14 @@ public ClassicHttpResponse executeRequest(Endpoint server, Map<String, Object> r
454454
if (httpResponse.getCode() == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
455455
throw new ClientMisconfigurationException("Proxy authentication required. Please check your proxy settings.");
456456
} else if (httpResponse.getCode() == HttpStatus.SC_BAD_GATEWAY) {
457+
httpResponse.close();
457458
throw new ClientException("Server returned '502 Bad gateway'. Check network and proxy settings.");
458459
} else if (httpResponse.getCode() >= HttpStatus.SC_BAD_REQUEST || httpResponse.containsHeader(ClickHouseHttpProto.HEADER_EXCEPTION_CODE)) {
459-
throw readError(httpResponse);
460+
try {
461+
throw readError(httpResponse);
462+
} finally {
463+
httpResponse.close();
464+
}
460465
}
461466
return httpResponse;
462467

0 commit comments

Comments
 (0)