BUG-5280: fix a thinko around sealed transactions 74/48274/3
authorRobert Varga <rovarga@cisco.com>
Fri, 11 Nov 2016 18:30:13 +0000 (19:30 +0100)
committerTom Pantelis <tpanteli@brocade.com>
Mon, 14 Nov 2016 16:04:07 +0000 (16:04 +0000)
Proxy transaction should check for not being sealed.

Change-Id: I7e7163d762a520a1899b09aa4fea4d10ab5e98c7
Signed-off-by: Tomas Cere <tcere@cisco.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractProxyTransaction.java

index cc1651a..9235f25 100644 (file)
@@ -63,27 +63,27 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
     }
 
     final void delete(final YangInstanceIdentifier path) {
-        checkSealed();
+        checkNotSealed();
         doDelete(path);
     }
 
     final void merge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
-        checkSealed();
+        checkNotSealed();
         doMerge(path, data);
     }
 
     final void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
-        checkSealed();
+        checkNotSealed();
         doWrite(path, data);
     }
 
     final CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
-        checkSealed();
+        checkNotSealed();
         return doExists(path);
     }
 
     final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
-        checkSealed();
+        checkNotSealed();
         return doRead(path);
     }
 
@@ -95,11 +95,15 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
      * Seals this transaction when ready.
      */
     final void seal() {
-        checkSealed();
+        checkNotSealed();
         doSeal();
         sealed = true;
     }
 
+    private void checkNotSealed() {
+        Preconditions.checkState(!sealed, "Transaction %s has already been sealed", getIdentifier());
+    }
+
     private void checkSealed() {
         Preconditions.checkState(sealed, "Transaction %s has not been sealed yet", getIdentifier());
     }
@@ -109,7 +113,7 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
      * being sent to the backend.
      */
     final void abort() {
-        checkSealed();
+        checkNotSealed();
         doAbort();
     }