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

Allow for multiple method parameters to be @MustCallAlias in Resource Leak Checker #4785

Closed
msridhar opened this issue Jul 6, 2021 · 0 comments · Fixed by #4808
Closed

Comments

@msridhar
Copy link
Contributor

msridhar commented Jul 6, 2021

(moving from kelloggm/object-construction-checker#409)

Right now, the Resource Leak Checker only supports writing @MustCallAlias on one formal parameter of a method, but we should generalize this. Consider SequenceInputStream:

https://docs.oracle.com/javase/7/docs/api/java/io/SequenceInputStream.html

For the Resource Leak Checker, I believe the correct qualifiers for this class are:

  • @MustCall({}) for the class
  • @MustCallAlias for both formal parameters of the SequenceInputStream(InputStream s1, InputStream s2) constructor

I believe the semantics are clear; when that constructor is invoked, the returned SequenceInputStream is a resource alias for both s1 and s2, and closing the SequenceInputStream will close both s1 and s2. I do not believe it will be terribly difficult to add support for this pattern to the checker.

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