RFR: 8295991: java/net/httpclient/CancelRequestTest.java fails intermittently

Daniel Fuchs dfuchs at openjdk.org
Wed Nov 2 11:47:20 UTC 2022


On Wed, 2 Nov 2022 05:04:44 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> The CancelRequestTest test has been observed failing (once). It was recently updated to verify that subscribers would be correctly unregistered after the request was cancelled. However, the timeout used to wait for that to happen was optimistically too short: the test code that cancels the request is by design racy, so it's not guaranteed that the subscriber will be unregistered before the completable future is cancelled, it might get unregistered asynchronously shortly after.
>> Increasing the timeout to wait for that to happen from 1ms to 100ms fixes the test issue.
>
> test/jdk/java/net/httpclient/CancelRequestTest.java line 382:
> 
>> 380:             assertEquals(latch.getCount(), 0);
>> 381: 
>> 382:             var error = TRACKER.check(100,
> 
> Hello Daniel, looking at the implementation in the `check` method of `ReferenceTracker`, it has this:
> 
> 
> public AssertionError check(long graceDelayMs,
>                             Predicate<Tracker> hasOutstanding,
>                             String description,
>                             boolean printThreads) {
>     AssertionError fail = null;
>     graceDelayMs = Math.max(graceDelayMs, 100);
> ...
> 
> So, even when we were passing it `1` milli seconds as a grace delay, it was changing it to `100` milli seconds. So I suspect the change in this PR won't have the intended effect since it would still wait the same amount of time and would potentially continue to have intermittent failures.

Ah! Good catch.

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

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


More information about the net-dev mailing list