The Checker Framework is flagging a possible null dereference in the below code snippet, where lambdaParameters.peek() is being checked for null before it is dereferenced. This seems to be a false positive, as the code should not cause a null dereference.
Code:
while (lambdaParameters.peek() != null
&& ast.equals(lambdaParameters.peek().enclosingLambda)) {
final Optional<LambdaParameterDetails> unusedLambdaParameter =
Optional.ofNullable(lambdaParameters.peek())
.filter(parameter -> !parameter.isUsed())
.filter(parameter -> !"_".equals(parameter.getName()));
....
}
Output:
New surviving error(s) found:
<checkerFrameworkError unstable="false">
<fileName>src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/UnusedLambdaParameterShouldBeUnnamedCheck.java</fileName>
<specifier>dereference.of.nullable</specifier>
<message>dereference of possibly-null reference lambdaParameters.peek()</message>
<lineContent>&& ast.equals(lambdaParameters.peek().enclosingLambda)) {</lineContent>
</checkerFrameworkError>
Expectations:
This issue appears to be a false positive because lambdaParameters.peek() is explicitly checked for nullity before any dereferencing occurs. The error persists even though the code logic should prevent a null dereference.
Build tool: maven
checker version: 3.46.0
The Checker Framework is flagging a possible null dereference in the below code snippet, where
lambdaParameters.peek()is being checked for null before it is dereferenced. This seems to be a false positive, as the code should not cause a null dereference.Code:
Output:
Expectations:
This issue appears to be a false positive because
lambdaParameters.peek()is explicitly checked for nullity before any dereferencing occurs. The error persists even though the code logic should prevent a null dereference.Build tool: maven
checker version: 3.46.0