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

Update Library Model Loader to mark fields Nullable #220

Merged
merged 15 commits into from
Dec 28, 2023

Conversation

nimakarimipour
Copy link
Member

@nimakarimipour nimakarimipour commented Dec 17, 2023

Followup on an update in NullAway recent change #878 which enables NullAway to mark fields as @Nullable. This PR updates our LibraryModelsLoader to enable communication of Annotator and NullAway to mark fields @Nullable while analyzing downstream dependencies. This is required to prepare the code for the upcoming change which enables Annotator to be informed of impacts of making fields @Nullable on downstream dependencies.

@nimakarimipour nimakarimipour added the enhancement New feature or request label Dec 17, 2023
@nimakarimipour nimakarimipour self-assigned this Dec 17, 2023
Copy link
Member

@msridhar msridhar left a comment

Choose a reason for hiding this comment

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

Overall looks good! I have a few comments. Also, why is nullable-methods.tsv checked in as an empty file?

Path path,
Function<AddAnnotation, Stream<String>> mapper) {
try (BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(path.toFile()))) {
Set<String> rows = annotations.flatMap(mapper).collect(Collectors.toSet());
for (String row : rows) {
os.write(row.getBytes(Charset.defaultCharset()), 0, row.length());
}
os.flush();
Copy link
Member

Choose a reason for hiding this comment

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

Not a big deal, but I don't think this call is needed, since the stream will immediately be closed afterward

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, fixed in f775354

Copy link
Member

Choose a reason for hiding this comment

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

I still see the call to os.flush()? Why is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is the call to os.flush() redundant (or guaranteed to be executed after the block) in try-with-resources block ? IntelliJ only grays out call to os.close() but not for os.flush().

Copy link
Member

Choose a reason for hiding this comment

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

try-with-resources guarantees the stream will be closed, and I believe it will be flushed automatically before it is closed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok thanks for that. Then we can remove it. Fixed in 24f0a24

@@ -82,6 +83,23 @@ public static void executeCommand(Config config, String command) {
}
}

/**
* Clears the content of the file at the given path if the file exists.
Copy link
Member

Choose a reason for hiding this comment

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

Why don't you just delete the file?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, that sounds better. Fixed in 6dd203e

Comment on lines 139 to 142
@Override
public ImmutableList<StreamTypeRecord> customStreamNullabilitySpecs() {
return LibraryModels.super.customStreamNullabilitySpecs();
}
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this override unnecessary? It just calls the super method?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for catching this, I really don't know what I was thinking 🤦🏻‍♂️ de61967

@nimakarimipour
Copy link
Member Author

Overall looks good! I have a few comments. Also, why is nullable-methods.tsv checked in as an empty file?

@msridhar Thank you very much for the review, this is ready for another round.

Regarding

Also, why is nullable-methods.tsv checked in as an empty file?

We weren't creating / deleting files in resource directory (which we are now 6dd203e). We used to assume the file exists and clear contents instead of deleting. With the new approach, we no longer need the file.

Copy link
Member

@msridhar msridhar left a comment

Choose a reason for hiding this comment

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

The PR still includes an empty nullable-methods.tsv file. After removing that file from the PR it looks good to go

@nimakarimipour
Copy link
Member Author

@msridhar I don't see the nullable-methods.tsv file on my branch. Isn't this PR actually deleting the existing nullable-methods.tsv on master branch ? Please let me know if I am missing something.

@msridhar
Copy link
Member

@msridhar I don't see the nullable-methods.tsv file on my branch. Isn't this PR actually deleting the existing nullable-methods.tsv on master branch ? Please let me know if I am missing something.

Yes, you're right. For some reason GitHub shows the change strangely. Locally git shows the file as removed. Sorry for the confusion.

@nimakarimipour
Copy link
Member Author

@msridhar Ok great, will land this one now and update #221.

@nimakarimipour nimakarimipour merged commit 9ecb823 into master Dec 28, 2023
6 checks passed
@nimakarimipour nimakarimipour deleted the nimak/update-library-model-loader branch December 28, 2023 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants