GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||
GeezerVison is showing github.com — [java] CloseResource - Fix #2764: False-negative when re-assigning variable by andipabst · Pull Request #2811 · pmd/pmd Conversation
Contributor
Describe the PRThis PR fixes a false-negative when re-assigning a variable without closing it before. Related issuesReady?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
Generated by 🚫 Danger |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good!
I've retriggered the travis build to get the pmd-regression-tester results. They should arrive soon at #2811 ...
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@andipabst
Now that the regression tester ran, there are some problems, see https://chunk.io/pmd/29b0228064074bb390f40398e6069462/diff/spring-framework/index.html
java.lang.NullPointerException
at net.sourceforge.pmd.lang.java.rule.errorprone.CloseResourceRule.isAssignmentForVariable(CloseResourceRule.java:733)
at net.sourceforge.pmd.lang.java.rule.errorprone.CloseResourceRule.isReassignedBeforeBeingClosed(CloseResourceRule.java:690)
at net.sourceforge.pmd.lang.java.rule.errorprone.CloseResourceRule.checkForResources(CloseResourceRule.java:172)
at net.sourceforge.pmd.lang.java.rule.errorprone.CloseResourceRule.visit(CloseResourceRule.java:156)
and
java.lang.NullPointerException
at net.sourceforge.pmd.lang.java.rule.errorprone.CloseResourceRule.isAssignmentForVariable(CloseResourceRule.java:735)
at net.sourceforge.pmd.lang.java.rule.errorprone.CloseResourceRule.isReassignedBeforeBeingClosed(CloseResourceRule.java:690)
at net.sourceforge.pmd.lang.java.rule.errorprone.CloseResourceRule.checkForResources(CloseResourceRule.java:172)
at net.sourceforge.pmd.lang.java.rule.errorprone.CloseResourceRule.visit(CloseResourceRule.java:156)
This might explain the false negatives in FastByteArrayOutputStreamTests.java
We seem to report now the initial assignment of the local var wrongly as a reassignment, e.g. https://chunk.io/pmd/29b0228064074bb390f40398e6069462/diff/spring-framework/index.html#A1
Could you please have another look? Thanks!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@adangel Thanks for showing me this. I added a check for null, but I am not sure if this fixes the regression, since I can not reproduce it in a unit test. Can you please tell me how I can run the regression test locally for myself? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@adangel Thank you, I did not notice that the top comment of the pmd-test bot was updated with the new result, my bad! I had missed another null check, but could find it, now the regression test is producing no more errors. I also changed the location of the violation. Now the error gets flagged on the reassignment instead of the initial declaration. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[java] CloseResourceRule does not recognize multiple assignment done to resource
There was an error while loading. Please reload this page.