Do not overwrite operation failure 48/31448/2
authorRobert Varga <rovarga@cisco.com>
Wed, 16 Dec 2015 15:44:40 +0000 (16:44 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 16 Dec 2015 16:22:54 +0000 (16:22 +0000)
When a ready-time failure occurs, do not overwrite it with a null
operation error (if no operations failed).

Change-Id: If2ac379e25af7bc93602b91ea5b068974a196771
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalThreePhaseCommitCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalTransactionContext.java

index 569bacc..442e2f3 100644 (file)
@@ -12,6 +12,7 @@ import akka.dispatch.Futures;
 import akka.dispatch.OnComplete;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.ListenableFuture;
+import javax.annotation.Nonnull;
 import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply;
 import org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransaction;
@@ -66,8 +67,12 @@ class LocalThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort {
         return actorContext.executeOperationAsync(leader, message, actorContext.getTransactionCommitOperationTimeout());
     }
 
-    void setOperationError(Exception operationError) {
-        this.operationError = operationError;
+    void setOperationError(@Nonnull Exception operationError) {
+        if (this.operationError != null) {
+            LOG.info("Cohort {} already had operation error", this, this.operationError);
+        }
+
+        this.operationError = Preconditions.checkNotNull(operationError);
     }
 
     Future<ActorSelection> initiateCoordinatedCommit() {
index 276523e..9398171 100644 (file)
@@ -113,7 +113,9 @@ abstract class LocalTransactionContext extends AbstractTransactionContext {
     private LocalThreePhaseCommitCohort ready() {
         logModificationCount();
         LocalThreePhaseCommitCohort cohort = readySupport.onTransactionReady(getWriteDelegate());
-        cohort.setOperationError(operationError);
+        if (operationError != null) {
+            cohort.setOperationError(operationError);
+        }
         return cohort;
     }
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.