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

NP_NONNULL_PARAM_VIOLATION with Checker Framework @Nullable #743

Open
skitt opened this issue Aug 28, 2018 · 2 comments
Open

NP_NONNULL_PARAM_VIOLATION with Checker Framework @Nullable #743

skitt opened this issue Aug 28, 2018 · 2 comments

Comments

@skitt
Copy link

skitt commented Aug 28, 2018

I'm aware this is supposed to be fixed by #539, and I have also tried to create this as a failing test in spotbugs (without success). However, building the following code:

import com.google.common.util.concurrent.Futures;
import java.util.concurrent.Future;

public class Test {
    private static final Future NULL_FUTURE = Futures.immediateFuture(null);
}

with the following POM:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.sk2</groupId>
    <artifactId>spotbugs-guava-test</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>26.0-jre</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs-maven-plugin</artifactId>
                <version>3.1.6</version>
                <configuration>
                    <failOnError>true</failOnError>
                </configuration>
                <executions>
                    <execution>
                        <id>analyze-compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

results in

[INFO] --- spotbugs-maven-plugin:3.1.6:check (analyze-compile) @ spotbugs-guava-test ---
[INFO] BugInstance size is 1
[INFO] Error size is 0
[INFO] Total bugs: 1
[ERROR] Null passed for non-null parameter of com.google.common.util.concurrent.Futures.immediateFuture(Object) in Test.<static initializer for Test>() [Test] At Test.java:[line 5] NP_NONNULL_PARAM_VIOLATION

even though immediateFuture is declared as

public static <V> ListenableFuture<V> immediateFuture(@Nullable V value)

with @Nullable from org.checkerframework.checker.nullness.qual (from Checker Framework 2.5.2).

Changing the Guava version to 25.0-jre “fixes” the issue. (That version used @NullableDecl.)

odl-github pushed a commit to opendaylight/odlparent that referenced this issue Sep 13, 2018
This re-synchronizes the two files, so downstreams can switch from
findbugs to spotbugs without a regression. Upsteam issue is still
tracked at spotbugs/spotbugs#743.

Change-Id: Iaf1b240bfed2892726b062b91890a2083705438b
JIRA: ODLPARENT-161
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
@KengoTODA
Copy link
Member

note: related change in Guava:

google/guava@0a2258e#diff-5c3f56c125a86c8adde4e8754f104468

@PhilippWendler
Copy link

This is the same as #643.

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

No branches or pull requests

3 participants