Skip to content

Improve required.method.not.called diagnostic messaging #1544

Open
thisisalexandercook wants to merge 5 commits intoeisop:masterfrom
thisisalexandercook:resource-leak-messaging
Open

Improve required.method.not.called diagnostic messaging #1544
thisisalexandercook wants to merge 5 commits intoeisop:masterfrom
thisisalexandercook:resource-leak-messaging

Conversation

@thisisalexandercook
Copy link
Copy Markdown
Collaborator

fixes #1542.

This PR improves Resource Leak Checker diagnostics for required.method.not.called to make them clearer and less misleading. It also normalizes reason text formatting (lowercase fragments and consistent spacing).

Sample output from latest commit:

checker/tests/resourceleak/RequiredMethodNotCalledMessage.java:19: error: [required.method.not.called] Required method close may not have been invoked on resource or any of its aliases.
        DemoResource resource = new DemoResource();
                     ^
  The type of object is: RequiredMethodNotCalledMessage.DemoResource.
  Reason for going out of scope: regular method exit
checker/tests/resourceleak/RequiredMethodNotCalledMessage.java:26: error: [required.method.not.called] Required method close may not have been invoked on resource or any of its aliases.
        DemoResource resource = new DemoResource();
                     ^
  The type of object is: RequiredMethodNotCalledMessage.DemoResource.
  Reason for going out of scope: possible exceptional exit before required method call, triggered by maybeThrows() throwing exception type java.io.IOException
checker/tests/resourceleak/RequiredMethodNotCalledMessage.java:37: error: [required.method.not.called] Required method close may not have been invoked on field field or any of its aliases.
            field = new DemoResource();
                  ^
  The type of object is: RequiredMethodNotCalledMessage.DemoResource.
  Reason for going out of scope: field assignment outside method or declaration might overwrite field's current value
checker/tests/resourceleak/RequiredMethodNotCalledMessage.java:43: error: [required.method.not.called] Required method close may not have been invoked on field field or any of its aliases.
            field = new DemoResource();
                  ^
  The type of object is: RequiredMethodNotCalledMessage.DemoResource.
  Reason for going out of scope: non-final owning field might be overwritten
4 errors

Copy link
Copy Markdown
Member

@wmdietl wmdietl left a comment

Choose a reason for hiding this comment

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

Thanks, that reads better than before.
@thisisalexandercook did you make sure the manual needs no updates?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Resource leak error messaging

2 participants