RFR: JDK-8303742: CompletableFuture.orTimeout leaks if the future completes exceptionally [v2]

Viktor Klang duke at openjdk.org
Thu Mar 16 21:12:51 UTC 2023


On Thu, 16 Mar 2023 20:51:29 GMT, Pavel Rappo <prappo at openjdk.org> wrote:

>> 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 <turbanoff at 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.

@pavelrappo Both good points—I'm updating it to use nanoTime + requiring 5M iterations of the loop to be safer.

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

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


More information about the core-libs-dev mailing list