|
Posted
4 months
ago
by
Oleg Kalnichevski
abernal Before we do anything, I would like to have a reasonable reproducer first, so we could reliably verify the fix. The request cancellation logic has existed for nearly 15 years, so I am somewhat skeptical a defect in it has gone unnoticed for Read more
|
|
Posted
4 months
ago
by
Arturo Bernal
olegk Agreed — I don’t think this is an HttpComponents defect per se. It’s a race inherent to cancellation / timeouts: a lease can complete concurrently with Future.get() timing out or being interrupted, and the caller never gets an endpoint to Read more
|
|
Posted
4 months
ago
by
Benjamin Peterson
As the opening post says, this issue can be triggered merely with timeouts also. Consider TimeoutLeakExample.java. This one seems to especially benefit from forcing virtual threads onto one platform thread like so: $ java -cp
Read more
|
|
Posted
4 months
ago
by
Benjamin Peterson
interrupts and timeouts may leak connections
|
|
Posted
4 months
ago
by
Oleg Kalnichevski
> With regards to request cancellation, is this what you mean? benjaminp No, it is not. As I tried to explain I am not sure the finally clause always gets executed if the thread just gets interrupted at a ransom time. You should be cancelling the Read more
|
|
Posted
4 months
ago
by
Benjamin Peterson
With regards to request cancellation, is this what you mean?
private static void doRequest(CloseableHttpClient httpClient) throws IOException, ParseException {
var httpGet = new HttpGet("https://www.example.com");
try (var response =
Read more
|
|
Posted
4 months
ago
by
Oleg Kalnichevski
benjaminp Why on earth are you cancelling some executor future and not the requests with Cancellable#cancel? I can see that some connections do not get released back to the pool but I am not sure the response objects get correctly closed in the first Read more
|
|
Posted
4 months
ago
by
Benjamin Peterson
Here's another version of my reproducer: HttpGetExample2.java It explicitly waits for executor termination to dispel any question about asynchronous cleanup. To more starkly demonstrate the leak, it attempts to run a request on the client after all Read more
|
|
Posted
4 months
ago
by
Benjamin Peterson
Consider InternalExecRuntime.acquireEndpoint:
try {
final ConnectionEndpoint connectionEndpoint = connRequest.get(connectionRequestTimeout);
} catch (final TimeoutException ex) {
Read more
|
|
Posted
4 months
ago
by
Benjamin Peterson
Consider {InternalExecRuntime.acquireEndpoint}}:
try {
final ConnectionEndpoint connectionEndpoint = connRequest.get(connectionRequestTimeout);
} catch (final TimeoutException ex) {
Read more
|