X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=dom%2Fmdsal-dom-spi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fmdsal%2Fdom%2Fspi%2FPingPongTransactionChain.java;h=09bd03255bedf95999a1b6ae0f8cae0f6506a938;hb=refs%2Fchanges%2F27%2F101027%2F3;hp=ec2b5a2d5eacc3d4b7f70dc93061992217ca16df;hpb=a5b5d9b7882531440d4c7335cd917b1e00075bc1;p=mdsal.git diff --git a/dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/PingPongTransactionChain.java b/dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/PingPongTransactionChain.java index ec2b5a2d5e..09bd03255b 100644 --- a/dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/PingPongTransactionChain.java +++ b/dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/PingPongTransactionChain.java @@ -8,9 +8,9 @@ package org.opendaylight.mdsal.dom.spi; import static com.google.common.base.Preconditions.checkState; -import static com.google.common.base.Verify.verify; import static java.util.Objects.requireNonNull; +import com.google.common.base.VerifyException; import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.MoreExecutors; @@ -263,8 +263,10 @@ public final class PingPongTransactionChain implements DOMTransactionChain { * correctness. */ private synchronized void processNextTransaction(final PingPongTransaction tx) { - final boolean success = INFLIGHT_UPDATER.compareAndSet(this, tx, null); - checkState(success, "Completed transaction %s while %s was submitted", tx, inflightTx); + if (!INFLIGHT_UPDATER.compareAndSet(this, tx, null)) { + throw new IllegalStateException(String.format("Completed transaction %s while %s was submitted", tx, + inflightTx)); + } final PingPongTransaction nextTx = READY_UPDATER.getAndSet(this, null); if (nextTx == null) { @@ -295,16 +297,20 @@ public final class PingPongTransactionChain implements DOMTransactionChain { void readyTransaction(final @NonNull PingPongTransaction tx) { // First mark the transaction as not locked. - final boolean lockedMatch = LOCKED_UPDATER.compareAndSet(this, tx, null); - checkState(lockedMatch, "Attempted to submit transaction %s while we have %s", tx, lockedTx); + if (!LOCKED_UPDATER.compareAndSet(this, tx, null)) { + throw new IllegalStateException(String.format("Attempted to submit transaction %s while we have %s", tx, + lockedTx)); + } LOG.debug("Transaction {} unlocked", tx); /* * The transaction is ready. It will then be picked up by either next allocation, * or a background transaction completion callback. */ - final boolean success = READY_UPDATER.compareAndSet(this, null, tx); - checkState(success, "Transaction %s collided on ready state", tx, readyTx); + if (!READY_UPDATER.compareAndSet(this, null, tx)) { + throw new IllegalStateException(String.format("Transaction %s collided on ready state with %s", tx, + readyTx)); + } LOG.debug("Transaction {} readied", tx); /* @@ -332,8 +338,10 @@ public final class PingPongTransactionChain implements DOMTransactionChain { synchronized void cancelTransaction(final PingPongTransaction tx, final DOMDataTreeReadWriteTransaction frontendTx) { // Attempt to unlock the operation. - final boolean lockedMatch = LOCKED_UPDATER.compareAndSet(this, tx, null); - verify(lockedMatch, "Cancelling transaction %s collided with locked transaction %s", tx, lockedTx); + if (!LOCKED_UPDATER.compareAndSet(this, tx, null)) { + throw new VerifyException(String.format("Cancelling transaction %s collided with locked transaction %s", tx, + lockedTx)); + } // Cancel the backend transaction, so we do not end up leaking it. final boolean backendCancelled = tx.getTransaction().cancel();