On Thu, 16 Mar 2023 20:51:37 GMT, Viktor Klang <d...@openjdk.org> wrote:

>> Addresses the situation where exceptional completion of `orTimeout`:ed 
>> CompletableFutures wouldn't cancel the timeout task which could lead to 
>> memory leaks if done frequently enough with long enough timeout durations.
>> 
>> Fix discussed with @DougLea
>
> Viktor Klang has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Update 
> test/jdk/java/util/concurrent/CompletableFuture/CompletableFutureOrTimeoutExceptionallyTest.java
>   
>   Co-authored-by: Andrey Turbanov <turban...@gmail.com>

test/jdk/java/util/concurrent/CompletableFuture/CompletableFutureOrTimeoutExceptionallyTest.java
 line 44:

> 42:     void testOrTimeoutWithCompleteExceptionallyDoesNotLeak() throws 
> Exception {
> 43:         var startTime = System.currentTimeMillis();
> 44:         var testRunTime = Duration.ofSeconds(10).toMillis();

This "create completable futures in a loop for t seconds" seems a bit brittle. 
Would 10 or 20 seconds be enough for a typical test machine to fail with OOME? 
Could this be improved by requiring a minimum number of CF instances to be 
created? Maybe finishing when t seconds have elapsed _and_ n instances have 
been created.

Separately, as with any timeouts, consider a monotonic clock.

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

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

Reply via email to