Skip to content

false positive RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE on try-with-resources #259

@jhonnen

Description

@jhonnen

FindBugs (eclipse plugin v3.0.1) reports a redundant null check on the closing brace of the following try-with-resources statement:

public void falsePositive() {
  try (X x = new X(); X y = new X()) {
    throw new IllegalStateException();
  } // Redundant nullcheck of x, which is known to be non-null in test.Bug1169.falsePositive()
}

private static class X implements AutoCloseable {
  @Override
  public void close() {
  }
}

The finding seems to be reported when more than one AutoClosable is used and the try block ends with a thrown exception.

Metadata

Metadata

Assignees

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