wwj6591812 commented on code in PR #8219:
URL: https://github.com/apache/paimon/pull/8219#discussion_r3417640044


##########
paimon-api/src/main/java/org/apache/paimon/rest/HttpClientUtils.java:
##########
@@ -86,9 +88,65 @@ private static HttpClientConnectionManager 
configureConnectionManager() {
     public static InputStream getAsInputStream(String uri) throws IOException {
         HttpGet httpGet = new HttpGet(uri);
         CloseableHttpResponse response = DEFAULT_HTTP_CLIENT.execute(httpGet);
-        if (response.getCode() != 200) {
-            throw new RuntimeException("HTTP error code: " + 
response.getCode());
+        int statusCode = response.getCode();
+        if (statusCode != HttpStatus.SC_OK) {
+            throw httpError(statusCode);

Review Comment:
   @JingsongLi 
   
   Good catch — getAsInputStream was throwing on non-200 responses without 
closing the CloseableHttpResponse, which could leak connections when many 
missing HTTP blobs are processed.
   
   I've updated the error branch to close the response in a finally block 
before throwing, while keeping the 200 path unchanged. I also added 
testGetAsInputStreamDoesNotLeakConnectionsOnRepeatedNotFound, which issues many 
consecutive 404 requests and then verifies a subsequent successful GET still 
works.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to