Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

false positive: NP_NONNULL_PARAM_VIOLATION on CompletableFuture.getNow(null) #1001

Open
ylexus opened this issue Aug 16, 2019 · 3 comments
Open

Comments

@ylexus
Copy link

ylexus commented Aug 16, 2019

spotbugs-maven-plugin:3.1.9 reports an error on a valid CompletableFuture.getNow(null) call:

import org.junit.jupiter.api.Test;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;

import static org.junit.jupiter.api.Assertions.assertThrows;

final class Github1001Test {
    @Test
    void name() {
        CompletableFuture<Object> future = new CompletableFuture<>();
        future.completeExceptionally(new RuntimeException("oops"));
        assertThrows(CompletionException.class, () -> future.getNow(null));
    }
}
[ERROR] Null passed for non-null parameter of java.util.concurrent.CompletableFuture.getNow(Object) in <...> NP_NONNULL_PARAM_VIOLATION

Unrelated, but the suppression (@SuppressFBWarnings("NP_NONNULL_PARAM_VIOLATION")) only works on class level in the example above, probably because the lambda is a static method on this class. Understandable, but very counter-intuitive.

@welcome
Copy link

welcome bot commented Aug 16, 2019

Thanks for opening your first issue here! 😃
Please check our contributing guideline. Especially when you report a problem, make sure you share a Minimal, Complete, and Verifiable example to reproduce it in this issue.

@ahubold
Copy link
Contributor

ahubold commented Sep 16, 2019

Same problem here. This one seems to be similar to #484 and DefaultNullnessAnnotations.java should be extended to allow null values for the getNow() method, similar to the fix for #484 in ac93f80

@b9r5
Copy link

b9r5 commented Feb 2, 2021

Same problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants