-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Remove SuppressWarnings from NoopLock.java #27416
Remove SuppressWarnings from NoopLock.java #27416
Conversation
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
assign set of reviewers |
Assigning reviewers. If you would like to opt out of this review, comment R: @bvolpato for label java. Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Run Java PreCommit |
sdks/java/core/src/main/java/org/apache/beam/sdk/util/NoopLock.java
Outdated
Show resolved
Hide resolved
sdks/java/core/src/main/java/org/apache/beam/sdk/util/NoopLock.java
Outdated
Show resolved
Hide resolved
@kennknowles related to #27416 (comment) and #27416 (comment), I'm thinking we are going to run into a lot of these issues as we clean up a lot of the SupressWarnings. I'm wondering if we should just maintain a like-for-like as much as the original author's intent unless we observe something breaking. What do you think? |
To your global comment: actually the issue with the repo is that the classes that exist are wrong and the process of fixing the nullness discipline is to make them right. Sometimes that just involves putting on a few annotations. Sometimes it involves refactors or redesigns because the original code cannot be made right. If we just wanted "like for like" then suppressing warnings on the places where we see warnings would do the trick. But then of course we still have all the same errors in the codebase. |
In other words, running into these issues and fixing them is the whole point. |
public class NoopLock implements Lock, Serializable { | ||
|
||
private static NoopLock instance; | ||
private static @MonotonicNonNull NoopLock instance; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kennknowles I chose @MonotonicNonNull here as per the JavaDoc it "Indicates that once the field (or variable) becomes non-null, it never becomes null again." I preferred this over the original @Nullable
as the static get
method along with the private constructor satisfies this condition.
|
||
public static NoopLock get() { | ||
public static @NonNull NoopLock get() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @NonNull
annotation seemed appropriate here given that the returned instance, if null, will always be instantiated.
run java precommit |
I didn't see why it was red but it also has be GC'd |
The tests were not green. Please do not merge when tests are failing. |
Even though the failures at https://ci-beam.apache.org/job/beam_PreCommit_Java_Phrase/6182/ are probably not related, please file tickets about the failures and kick the tests to get them green. Merging on red embraces the flakey lifestyle, which we don't want to do. |
* Remove SuppressWarnings from NoopLock.java * Remove Nonnull annotations from original
This PR addresses #20507 by removing the
@SuppressWarnings
annotation from sdks/java/core/src/main/java/org/apache/beam/sdk/util/NoopLock.java.Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123
), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>
instead.UpdateCHANGES.md
with noteworthy changes.If this contribution is large, please file an Apache Individual Contributor License Agreement.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI.