Skip to content

False positive RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE and NP_LOAD_OF_KNOWN_NULL_VALUE when using empty try-with-resources #647

@nickantzoulis

Description

@nickantzoulis
public void falsePositive(Path myPath) throws IOException {
    try (InputStream inStream = java.nio.file.Files.newInputStream(myPath)) {
       // commented out code
    }
}

The preceding code produces 2 false positives:
-RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE
-NP_LOAD_OF_KNOWN_NULL_VALUE

Using jdk 1.8.0_172, spotbugs version 3.1.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions