You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by GitBox <gi...@apache.org> on 2022/06/10 18:32:26 UTC

[GitHub] [httpcomponents-client] carterkozak opened a new pull request, #371: HTTPCLIENT-2221 Closing a classic response/entity allows connection reuse

carterkozak opened a new pull request, #371:
URL: https://github.com/apache/httpcomponents-client/pull/371

   Previously, a partially consumed response body closed via
   CloseableHttpResponse.close or HttpEntity.close would fully consume
   remaining bytes (via close), however it would not release the
   connection for reuse.
   If CloseableHttpResponse.close was called, it would follow the close
   with a discard/disconnect, however if only the entity was closed,
   the connection would remain in a checked-out (leaked) state.
   
   Now, we take advantage of the fact that closing a response stream
   on any reusable connection is required to drain bytes on closure.
   Failures are detected by writeTo and the stream returned by
   getContent, so we can be confident that we will not return a
   broken connection to the pool.


-- 
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: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] carterkozak commented on a diff in pull request #371: HTTPCLIENT-2221 Closing a classic response/entity allows connection reuse

Posted by GitBox <gi...@apache.org>.
carterkozak commented on code in PR #371:
URL: https://github.com/apache/httpcomponents-client/pull/371#discussion_r894801063


##########
httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionReuse.java:
##########
@@ -197,8 +204,10 @@ public void testReuseOfAbortedConnections() throws Exception {
             }
         }
 
-        // Expect zero connections in the pool
-        Assertions.assertEquals(0, this.connManager.getTotalStats().getAvailable());
+        // Expect leased connections to be returned
+        Assertions.assertEquals(0, this.connManager.getTotalStats().getLeased());
+        // Expect some connections in the pool
+        Assertions.assertTrue(this.connManager.getTotalStats().getAvailable() > 0);

Review Comment:
   Previously this test expected connections to be closed, however the response was fully drained and ready for reuse.



-- 
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: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] ok2c merged pull request #371: HTTPCLIENT-2221 Closing a classic response/entity allows connection reuse

Posted by GitBox <gi...@apache.org>.
ok2c merged PR #371:
URL: https://github.com/apache/httpcomponents-client/pull/371


-- 
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: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org