Skip to content

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

Open
thisisalexandercook wants to merge 7 commits into
eisop:masterfrom
thisisalexandercook:resource-leak-messaging
Open

Improve required.method.not.called diagnostic messaging #1544
thisisalexandercook wants to merge 7 commits into
eisop: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

@wmdietl wmdietl left a comment

Copy link
Copy Markdown
Member

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?

@wmdietl

wmdietl commented May 2, 2026

Copy link
Copy Markdown
Member

@thisisalexandercook Please merge in master and move the fixed issue number to the next release.
Please check whether the error messages appear anywhere else in the repo, e.g. in the manual, and update them if needed.
Thanks!

@thisisalexandercook

Copy link
Copy Markdown
Collaborator Author

Only the error key appears in the manual so no updates should be needed.

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