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 569bacceaa8f600f4110ddafb106f34dbccac881..442e2f3b4dd77c88cfb3b57e868f5f5ed0a4d4fc 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 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;
 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());
     }
 
         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() {
     }
 
     Future<ActorSelection> initiateCoordinatedCommit() {
index 276523e680a6389210edf290fff1a32fff252f23..9398171b202bd2f05a5d9028946ebe26d44ce175 100644 (file)
@@ -113,7 +113,9 @@ abstract class LocalTransactionContext extends AbstractTransactionContext {
     private LocalThreePhaseCommitCohort ready() {
         logModificationCount();
         LocalThreePhaseCommitCohort cohort = readySupport.onTransactionReady(getWriteDelegate());
     private LocalThreePhaseCommitCohort ready() {
         logModificationCount();
         LocalThreePhaseCommitCohort cohort = readySupport.onTransactionReady(getWriteDelegate());
-        cohort.setOperationError(operationError);
+        if (operationError != null) {
+            cohort.setOperationError(operationError);
+        }
         return cohort;
     }
 
         return cohort;
     }