Skip to content
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

[69] NullPointer exception in eco code java Sonar plugin #70

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rrousset-michelin
Copy link

No description provided.

@dedece35 dedece35 linked an issue Oct 4, 2024 that may be closed by this pull request
@@ -0,0 +1,45 @@
package files;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename this test class with an explicit name corresponding to use case instead of "2"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will done it if you want after the merge of this PR (if you don't have time to do it)

* The "try" should have been poped from the stack before entering here
*/
private void calledMethodWithoutTry() throws IOException {
FileWriter myWriter = new FileWriter("somefilepath");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, but for me, this use case is an "non compliant" case.
This is a good example explaining that if the FileWriter is instanciated inside a private method, it must be protected with a try-with-resource. In this case, it must be done.
Sorry I can't accept the correction ... for me, the global algorithm must be refactored to manage this use case !

Copy link

sonarcloud bot commented Oct 28, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NullPointer exception in eco code java Sonar plugin
2 participants