Skip to content

Commit

Permalink
Remove SuppressWarnings from NoopLock.java (#27416)
Browse files Browse the repository at this point in the history
* Remove SuppressWarnings from NoopLock.java

* Remove Nonnull annotations from original
  • Loading branch information
damondouglas authored Jul 20, 2023
1 parent 549bbfc commit b610846
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

public static NoopLock get() {
public static @NonNull NoopLock get() {
if (instance == null) {
instance = new NoopLock();
}
Expand All @@ -56,14 +54,13 @@ public boolean tryLock() {
}

@Override
public boolean tryLock(long time, @Nonnull TimeUnit unit) {
public boolean tryLock(long time, TimeUnit unit) {
return true;
}

@Override
public void unlock() {}

@Nonnull
@Override
public Condition newCondition() {
throw new UnsupportedOperationException("Not implemented");
Expand Down

0 comments on commit b610846

Please sign in to comment.