jborgers/PMD-jPinpoint-rules

Fix Request: AvoidFutureJoinWithoutTimeout with CompletableFuture.allOf using varargs

Closed this issue · 2 comments

AvoidFutureJoinWithoutTimeout is not triggered when a join is performed on a Future which was created with CompletableFuture.allOf(CompletableFuture, CompletableFuture, ...). Similar to #216.

    public void getUserDetail(String userId) {
        CompletableFuture<Optional<String>> firstCompletableFuture = firstService.getFirst(userId);
        CompletableFuture<Optional<String>> secondCompletableFuture = secondService.getSecond(userId);

        CompletableFuture.allOf(firstCompletableFuture, secondCompletableFuture).join(); // blocks without timeout, not detected

        Optional<String> userProfile = firstCompletableFuture.get(COMPLETABLE_FUTURE_TIMEOUT_IN_MS, TimeUnit.MILLISECONDS);
        Optional<String> userAccounts = secondCompletableFuture.get(COMPLETABLE_FUTURE_TIMEOUT_IN_MS, TimeUnit.MILLISECONDS);
    }

This example actually gives a violation. Cannot reproduce.

You are right, I seem to have simplified the example a bit too much as it needs the _get_s on the CompletableFuture to not get detected by the rules. Updated the example.