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 RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE on try-with-resources #259
Comments
Please have a try with SpotBugs, it should be already solved by SpotBugs. |
@KengoTODA I've reproduced the same false positive with the eclipse spotbugs plugin 3.1.0.20170610-1497060633070:
Note that the finding is filtered with initial settings since it's rank 20 and low confidence. |
still occuring using 3.1.7:
Nullcheck of con at line ... of value previously dereferenced in ...[line <meta =>]Redundant null check at ...:[line ] RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE |
Can confirm this is still an issue. Ping pong |
This bug affects checkstyle openjdk 11 build:
The lines 411-413 of main.java are
|
Having the same false positive with v3.1.10. Using maven plugin. Let me elaborate a little about the cause of this issue. There we can clearly see how resources are declared as local variables before try statement and thereafter closed in finally block first being checked for nullity. And here we get redundant null check warning because that variable was used in our try block. I don't know the code base of Spotbugs and quick overview didn't revealed details of its working, so I didn't try to make a fix. I hope that will be fixed soon or, if not, I may spend some time on my spare time. |
Happened to me too, SpotBugs 3.1.8, try-with-resources, Java 11 |
+1 Eclipse Plugin 3.1.10r201812180244 |
#284 has proved that the reported problem has been solved. So I think yours is different and new problem. Please consider to make an unit test to reproduce, and submit PR to merge it to release-3.1 branch. 🙇 |
Can confirm this still affects Spotbugs 3.1.10, hopefully #259 will show that not all cases are fixed yet. |
Is this related to #756? |
still problem on 3.1.12.2 |
* Bump maven-checkstyle-plugin from 3.1.0 to 3.1.1 - closes #150 * Update xds references in configuration files - update changed checkstyle modules * Convert internal pipeline to declarative form * Remove copyright header * Remove copyright header * Revise POM configuration regarding updated static code analysis - update rules of static code analysis configurations - use properties for CheckStyle configuration - fail the build for all violations in analysis results - use prepared dependencies for PMD check - add contributor, issue and CI management section - add fast profile without validation steps * Sync IDEA settings with static code analysis configurations - extend editorconfig with all IDEA specific settings * Share IDEA run configurations * CheckStyle: Fix JavadocParagraph violations - remove @author tag to prevent parse error - details: no viable alternative at input '<christian.poenisch@' while parsing HTML_ELEMENT * CheckStyle: Fix FinalParameters * CheckStyle: Fix SummaryJavadoc * CheckStyle: Fix FinalLocalVariable * CheckStyle: Fix JavaDocMethod and MissingJavadocMethod * CheckStyle: Remove HiddenField module * CheckStyle: Remove ReturnCount module * CheckStyle: Fix JavadocParagraph * CheckStyle: Fix SeparatorWrap * CheckStyle: Fix several minor violations * CheckStyle: Fix OperatorWrap, DeclarationOrder, OverloadMethodsDeclarationOrder - enable SuppressWarningsFilter * PMD: Fix violations * CheckStyle: Fix Indentation * CheckStyle: Fix OperatorWrap * CheckStyle: Remove NoClone module * CheckStyle: Fix NoFinalizer, ParameterAssignment, IllegalCatch * Enable to scan resources for CheckStyle violations - set UTF-8 encoding for the whole project * CheckStyle: Fix properties files * Fix CasC IT for TEST-GUIDE installation * Fix several found issues of IDEA analysis inspection results - unnecessary throws, suppress warnings - public inner static classes - generic types - unused return types * SpotBugs: Fix or suppress all warnings - use prepared statements for SQL queries - fix inner serializable classes - suppress transient field warnings * Enable CheckStyle and PMD by default - ignore all generated and test sources for CheckStyle * Cache Maven dependencies for GitHub CI workflow - change to verify goal to include static code analysis - limit to PRs to master * Fix synchronizing ATX default settings * Fix overriding ATX settings from pipeline * Fix showing ATX settings groups - revise tests * Fix redundant NP checks * Avoid NP check for applicable ATX custom settings * Ignore NP checks for all Launcher.getChannel() calls * Ignore false positive NP checks in try-with-resources - see: spotbugs/spotbugs#259 * Move ToolVersion to util package * Set default value for usePersistedSettings checkbox
Still persists on 4.0.0 |
…er as they might fail when using try-with-resource statements as of spotbugs/spotbugs#259 and spotbugs/spotbugs#756
* ci: build with Java 11 * build: configure Gradle to use --release option As a workaround for #996, skip the compilation for Bug1169.java in soitbugsTestCases project. * build: fix a typo in the build script * fix: ignore RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE right after try-block close #259 * docs: add CHANGELOG entry to describe the fix
Hi @KengoTODA . |
I've made a very small sample project to reproduce #259 (and also #811) with Spotbugs 4.1.3: https://github.com/Zlika/spotbugs-bug259 |
The problem seems to be fixed by upgrading the spotbugs-maven-plugin to version 4.1.3. Previously I used spotbugs-maven-plugin 4.0.4 with a forced dependency to spotbugs 4.1.3 (as in https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/upgrading-checkstyle.html). This seems to have some side effects. |
We still have the issue with 4.2.2 :-(. (false positive inside try with resources block) |
…LL_VALUE in Java 11 This should fix issue spotbugs#600 and spotbugs#1338. I also fixed the broken tests for spotbugs#259.
…LL_VALUE in Java 11 This should fix issue spotbugs#600 and spotbugs#1338. I also fixed the broken tests for spotbugs#259.
FindBugs (eclipse plugin v3.0.1) reports a redundant null check on the closing brace of the following try-with-resources statement:
The finding seems to be reported when more than one AutoClosable is used and the try block ends with a thrown exception.
The text was updated successfully, but these errors were encountered: