Remove RV_RETURN_VALUE_IGNORED FB supression
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardDataTree.java
index 7f3476090bb9a3a177e4999f41c3a18768949d3c..bc9549a64071649daf33ee06e66a2a78dcd0511e 100644 (file)
@@ -13,6 +13,7 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Stopwatch;
+import com.google.common.base.Ticker;
 import com.google.common.base.Verify;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
@@ -77,7 +78,8 @@ import scala.concurrent.duration.Duration;
  * Internal shard state, similar to a DOMStore, but optimized for use in the actor system,
  * e.g. it does not expose public interfaces and assumes it is only ever called from a
  * single thread.
- * <p/>
+ *
+ * <p>
  * This class is not part of the API contract and is subject to change at any time.
  */
 @NotThreadSafe
@@ -135,10 +137,14 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
                 new DefaultShardDataChangeListenerPublisher(), "");
     }
 
-    String logContext() {
+    final String logContext() {
         return logContext;
     }
 
+    final Ticker ticker() {
+        return shard.ticker();
+    }
+
     public TipProducingDataTree getDataTree() {
         return dataTree;
     }
@@ -367,7 +373,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
         }
     }
 
-    private ShardDataTreeTransactionChain ensureTransactionChain(final LocalHistoryIdentifier localHistoryIdentifier) {
+    ShardDataTreeTransactionChain ensureTransactionChain(final LocalHistoryIdentifier localHistoryIdentifier) {
         ShardDataTreeTransactionChain chain = transactionChains.get(localHistoryIdentifier);
         if (chain == null) {
             chain = new ShardDataTreeTransactionChain(localHistoryIdentifier, this);
@@ -475,7 +481,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
         final DataTreeModification snapshot = transaction.getSnapshot();
         snapshot.ready();
 
-        return createReadyCohort(transaction.getId(), snapshot);
+        return createReadyCohort(transaction.getIdentifier(), snapshot);
     }
 
     public Optional<NormalizedNode<?, ?>> readNode(final YangInstanceIdentifier path) {
@@ -668,6 +674,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
         cohortRegistry.process(sender, message);
     }
 
+    @Override
     ShardDataTreeCohort createReadyCohort(final TransactionIdentifier txId,
             final DataTreeModification modification) {
         SimpleShardDataTreeCohort cohort = new SimpleShardDataTreeCohort(this, modification, txId,
@@ -676,8 +683,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
         return cohort;
     }
 
-    @SuppressFBWarnings(value = {"RV_RETURN_VALUE_IGNORED", "DB_DUPLICATE_SWITCH_CLAUSES"},
-            justification = "See inline comments below.")
+    @SuppressFBWarnings(value = "DB_DUPLICATE_SWITCH_CLAUSES", justification = "See inline comments below.")
     void checkForExpiredTransactions(final long transactionCommitTimeoutMillis) {
         final long timeout = TimeUnit.MILLISECONDS.toNanos(transactionCommitTimeoutMillis);
         final long now = shard.ticker().read();
@@ -688,16 +694,16 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
             boolean processNext = true;
             switch (currentTx.cohort.getState()) {
                 case CAN_COMMIT_PENDING:
-                    pendingTransactions.poll().cohort.failedCanCommit(new TimeoutException());
+                    pendingTransactions.remove().cohort.failedCanCommit(new TimeoutException());
                     break;
                 case CAN_COMMIT_COMPLETE:
                     // The suppression of the FindBugs "DB_DUPLICATE_SWITCH_CLAUSES" warning pertains to this clause
                     // whose code is duplicated with PRE_COMMIT_COMPLETE. The clauses aren't combined in case the code
                     // in PRE_COMMIT_COMPLETE is changed.
-                    pendingTransactions.poll().cohort.reportFailure(new TimeoutException());
+                    pendingTransactions.remove().cohort.reportFailure(new TimeoutException());
                     break;
                 case PRE_COMMIT_PENDING:
-                    pendingTransactions.poll().cohort.failedPreCommit(new TimeoutException());
+                    pendingTransactions.remove().cohort.failedPreCommit(new TimeoutException());
                     break;
                 case PRE_COMMIT_COMPLETE:
                     // FIXME: this is a legacy behavior problem. Three-phase commit protocol specifies that after we
@@ -717,7 +723,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
                     //        In order to make the pre-commit timer working across failovers, though, we need
                     //        a per-shard cluster-wide monotonic time, so a follower becoming the leader can accurately
                     //        restart the timer.
-                    pendingTransactions.poll().cohort.reportFailure(new TimeoutException());
+                    pendingTransactions.remove().cohort.reportFailure(new TimeoutException());
                     break;
                 case COMMIT_PENDING:
                     LOG.warn("{}: Transaction {} is still committing, cannot abort", logContext,
@@ -730,10 +736,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
                 case FAILED:
                 case READY:
                 default:
-                    // The suppression of the FindBugs "RV_RETURN_VALUE_IGNORED" warning pertains to this line. In
-                    // this case, we just want to drop the current entry that expired and thus ignore the return value.
-                    // In fact we really shouldn't hit this case but we handle all enums for completeness.
-                    pendingTransactions.poll();
+                    pendingTransactions.remove();
             }
 
             if (processNext) {
@@ -742,7 +745,6 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
         }
     }
 
-    @SuppressFBWarnings(value = "RV_RETURN_VALUE_IGNORED", justification = "See inline comment below.")
     void startAbort(final SimpleShardDataTreeCohort cohort) {
         final Iterator<CommitEntry> it = pendingTransactions.iterator();
         if (!it.hasNext()) {
@@ -757,10 +759,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
                 LOG.debug("{}: aborted head of queue {} in state {}", logContext, cohort.getIdentifier(),
                     cohort.getIdentifier());
 
-                // The suppression of the FindBugs "RV_RETURN_VALUE_IGNORED" warning pertains to this line. In
-                // this case, we've already obtained the head of the queue above via the Iterator and we just want to
-                // remove it here.
-                pendingTransactions.poll();
+                pendingTransactions.remove();
                 processNextTransaction();
             } else {
                 LOG.warn("{}: transaction {} is committing, skipping abort", logContext, cohort.getIdentifier());