damondouglas commented on code in PR #27416:
URL: https://github.com/apache/beam/pull/27416#discussion_r1264741373


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/util/NoopLock.java:
##########
@@ -21,21 +21,19 @@
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
-import javax.annotation.Nonnull;
+import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
+import org.checkerframework.checker.nullness.qual.NonNull;
 
 /**
  * A lock which can always be acquired. It should not be used when a proper 
lock is required, but it
  * is useful as a performance optimization when locking is not necessary but 
the code paths have to
  * be shared between the locking and the non-locking variant.
  */
-@SuppressWarnings({
-  "nullness" // TODO(https://github.com/apache/beam/issues/20497)
-})
 public class NoopLock implements Lock, Serializable {
 
-  private static NoopLock instance;
+  private static @MonotonicNonNull NoopLock instance;

Review Comment:
   @kennknowles I chose 
[@MonotonicNonNull](https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/MonotonicNonNull.html)
 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.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to