On Mon, 17 Oct 2022 19:21:17 GMT, Daniel Fuchs <[email protected]> wrote:

>> When [JDK-8277969](https://bugs.openjdk.org/browse/JDK-8277969) was 
>> implemented, a list of outstanding response subscribers was added to 
>> `HttpClientImpl`. A body subscriber is added to the list after being created 
>> and is removed from the list when it is completed, either successfully or 
>> exceptionally.
>> 
>> It appears that in the case where the subscription is cancelled before the 
>> subscriber is completed, the subscriber might remain registered in the list 
>> forever, or at least until the HttpClient gets garbage collected. This can 
>> be easily reproduced using streaming subscribers, such as 
>> BodySubscriber::ofInputStream. In the case where the input stream is closed 
>> without having read all the bytes, Subscription::cancel will be called. 
>> Whether the subscriber gets unregistered or not at that point becomes racy.
>> 
>> Indeed, the reactive stream specification doesn't guarantee whether 
>> onComplete or onError will be called or not after a subscriber cancels its 
>> subscription. Any cleanup that would have been performed by 
>> onComplete/onError might therefore need to be performed when the 
>> subscription is cancelled too.
>
> Daniel Fuchs has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Update copyright years

test/jdk/java/net/httpclient/SmallTimeout.java line 184:

> 182: 
> 183:             executor.shutdownNow();
> 184:             if (!executor.awaitTermination(500, TimeUnit.MILLISECONDS)) {

Would this timeout value (whatever value we decide) introduce any potential 
intermittent failures, especially on CI systems? Would it perhaps be better to 
just call `executor.close()` after that call to `executor.shutdownNow()`, so 
that if the tasks really don't complete, then the jtreg test timeout will make 
it fail with a timeout and we don't have to decide what timeout is a good 
timeout?

-------------

PR: https://git.openjdk.org/jdk/pull/10659

Reply via email to