Skip to content

Add library model for Guava's Closer.register - #632

Merged
lazaroclapp merged 1 commit into
masterfrom
lazaro_guava_31_model_closer
Aug 5, 2022
Merged

lazaroclapp merged 1 commit into
masterfrom
lazaro_guava_31_model_closer

Conversation

@lazaroclapp

Copy link
Copy Markdown
Collaborator

This is a follow up to #628 and our support for @ParametricNullness in NullAway 0.9.9.
It turns out that com.google.common.io.Closer annotates it's register method as:

  @CanIgnoreReturnValue
  @ParametricNullness
  public <C extends @Nullable Closeable> C register(@ParametricNullness C closeable) {...}

Where the return is only really @Nullable if the argument is @Nullable (it is the same reference).

This PR adds a Library Model for this method, which is equivalent to adding the @Contract("null -> null")
annotation to it.

Note that, in order for this model to be helpful, AcknowledgeLibraryModelsOfAnnotatedCode
must be set, which would seem to argue for making that the default.

@lazaroclapp
lazaroclapp requested a review from msridhar August 5, 2022 02:30
@lazaroclapp

Copy link
Copy Markdown
Collaborator Author

Ran into this case while upgrading internally (used in tooling, so my usual sanity tests pre-release missed it πŸ˜… )

@coveralls

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build #901

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 92.49%

Totals Coverage Status
Change from base Build #900: 0.001%
Covered Lines: 4803
Relevant Lines: 5193

πŸ’› - Coveralls

@msridhar

msridhar commented Aug 5, 2022

Copy link
Copy Markdown
Collaborator

Note that, in order for this model to be helpful, AcknowledgeLibraryModelsOfAnnotatedCode
must be set, which would seem to argue for making that the default.

Maybe we should just get rid of the flag entirely? I'm not sure how likely it is that a user will have a library model for annotated code and will prefer the annotations in the code. I'm also fine with turning the flag on by default if we want to preserve the option.

@lazaroclapp

lazaroclapp commented Aug 5, 2022 •

Copy link
Copy Markdown
Collaborator Author

Note that, in order for this model to be helpful, AcknowledgeLibraryModelsOfAnnotatedCode
must be set, which would seem to argue for making that the default.

Maybe we should just get rid of the flag entirely? I'm not sure how likely it is that a user will have a library model for annotated code and will prefer the annotations in the code. I'm also fine with turning the flag on by default if we want to preserve the option.

I think for next release we should keep the flag and just flip the default just in case. I do worry that we will forget and never remove the flag, though... in either case, will make that as a separate PR if only for better Changelog tracking πŸ™‚

@lazaroclapp
lazaroclapp merged commit a8051cd into master Aug 5, 2022
@lazaroclapp
lazaroclapp deleted the lazaro_guava_31_model_closer branch August 5, 2022 16:59
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.

3 participants