Change RTE to an ISE
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / databroker / actors / dds / VotingFuture.java
index b6aba31e50982bc47d679189ea3f017cad9e2724..6433b6b5878be65d11507dbfd14d25d73fbe7eb5 100644 (file)
@@ -7,14 +7,17 @@
  */
 package org.opendaylight.controller.cluster.databroker.actors.dds;
 
-import com.google.common.base.Preconditions;
-import com.google.common.base.Verify;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Verify.verify;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.util.concurrent.AbstractFuture;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
-import javax.annotation.concurrent.GuardedBy;
+import org.checkerframework.checker.lock.qual.GuardedBy;
+import org.checkerframework.checker.lock.qual.Holding;
 
 /**
  * An {@link AbstractFuture} implementation which requires a certain number of votes before it completes. If all votes
@@ -22,6 +25,7 @@ import javax.annotation.concurrent.GuardedBy;
  * an exception. This exception corresponds to the cause reported by the first 'no' vote, with all subsequent votes
  * added as suppressed exceptions.
  *
+ * <p>
  * Implementation is geared toward positive votes. Negative votes have to synchronize and therefore are more likely
  * to see contention.
  *
@@ -42,18 +46,17 @@ class VotingFuture<T> extends AbstractFuture<T> {
     private volatile int neededVotes;
 
     VotingFuture(final T result, final int requiredVotes) {
-        Preconditions.checkArgument(requiredVotes > 0);
+        this.result = requireNonNull(result);
+        checkArgument(requiredVotes > 0);
         this.neededVotes = requiredVotes;
 
-        // null is okay to allow Void type
-        this.result = result;
     }
 
     void voteYes() {
         if (castVote()) {
             synchronized (failures) {
                 resolveResult();
-             }
+            }
         }
     }
 
@@ -68,11 +71,11 @@ class VotingFuture<T> extends AbstractFuture<T> {
 
     private boolean castVote() {
         final int votes = VOTES_UPDATER.decrementAndGet(this);
-        Verify.verify(votes >= 0);
+        verify(votes >= 0);
         return votes == 0;
     }
 
-    @GuardedBy("failures")
+    @Holding("failures")
     private void resolveResult() {
         final Iterator<Throwable> it = failures.iterator();
         if (!it.hasNext()) {