Fix Verify/Preconditions string format 66/59866/3
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 3 Jul 2017 08:17:54 +0000 (10:17 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 10 Jul 2017 11:17:11 +0000 (13:17 +0200)
These methods take a String.format() string, not a logging one, hence
we are not getting the information we want.

Change-Id: I46de0d64c85594e3d7b8be97951f1cf5249bca8f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3e9ac68fea1aef0c7fedec346e50882efdde8acc)

opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/InternalJMXRegistrator.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/TransmitQueue.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractShardBackendResolver.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/LocalReadWriteProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTree.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongTransactionChain.java
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractSnapshotBackedTransactionChain.java

index 97c4280..7a1a74e 100644 (file)
@@ -437,8 +437,8 @@ class ConfigTransactionControllerImpl implements
                 LOG.debug("About to commit {} in transaction {}",
                         moduleIdentifier, getTransactionIdentifier());
                 AutoCloseable instance = module.getInstance();
-                Preconditions.checkNotNull(instance, "Instance is null:{} in transaction {}", moduleIdentifier, getTransactionIdentifier());
-            } catch (final Exception e) {
+                Preconditions.checkNotNull(instance, "Instance is null:%s in transaction %s", moduleIdentifier, getTransactionIdentifier());
+            } catch (Exception e) {
                 LOG.error("Commit failed on {} in transaction {}", moduleIdentifier,
                         getTransactionIdentifier(), e);
                 internalAbort();
index 147d6ee..7d0bee2 100644 (file)
@@ -88,7 +88,7 @@ abstract class InternalJMXRegistrator implements AutoCloseable {
     final synchronized void unregisterMBean(final ObjectName on) {
         // first check that on was registered using this instance
         boolean removed = registeredObjectNames.remove(on);
-        Preconditions.checkState(removed, "Cannot unregister - ObjectName not found in 'registeredObjectNames': {}", on);
+        Preconditions.checkState(removed, "Cannot unregister - ObjectName not found in 'registeredObjectNames': %s", on);
 
         try {
             getMBeanServer().unregisterMBean(on);
index ae047ef..6f283f5 100644 (file)
@@ -246,7 +246,7 @@ abstract class TransmitQueue {
     }
 
     final void setForwarder(final ReconnectForwarder forwarder, final long now) {
-        Verify.verify(successor == null, "Successor {} already set on connection {}", successor, this);
+        Verify.verify(successor == null, "Successor %s already set on connection %s", successor, this);
         successor = Preconditions.checkNotNull(forwarder);
         LOG.debug("Connection {} superseded by {}, splicing queue", this, successor);
 
index 07b89e0..2988c39 100644 (file)
@@ -364,7 +364,7 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
     void sealOnly() {
         parent.onTransactionSealed(this);
         final boolean success = STATE_UPDATER.compareAndSet(this, OPEN, SEALED);
-        Verify.verify(success, "Attempted to replay seal on {}", this);
+        Verify.verify(success, "Attempted to replay seal on %s", this);
     }
 
     /**
index a1ddcc3..46e035d 100644 (file)
@@ -152,7 +152,7 @@ abstract class AbstractShardBackendResolver extends BackendInfoResolver<ShardBac
                 }
 
                 LOG.debug("Resolved backend information to {}", response);
-                Preconditions.checkArgument(response instanceof ConnectClientSuccess, "Unhandled response {}",
+                Preconditions.checkArgument(response instanceof ConnectClientSuccess, "Unhandled response %s",
                     response);
                 final ConnectClientSuccess success = (ConnectClientSuccess) response;
                 future.complete(new ShardBackendInfo(success.getBackend(), nextSessionId.getAndIncrement(),
index c44e70e..77e2a6a 100644 (file)
@@ -249,7 +249,7 @@ final class LocalReadWriteProxyTransaction extends LocalProxyTransaction {
 
         final Optional<PersistenceProtocol> maybeProtocol = request.getPersistenceProtocol();
         if (maybeProtocol.isPresent()) {
-            Verify.verify(callback != null, "Request {} has null callback", request);
+            Verify.verify(callback != null, "Request %s has null callback", request);
             if (markSealed()) {
                 sealOnly();
             }
index 99c0376..277c09f 100644 (file)
@@ -699,11 +699,11 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat
         public CDSShardAccess getShardAccess(@Nonnull final DOMDataTreeIdentifier subtree) {
             Preconditions.checkArgument(
                     subtrees.stream().anyMatch(dataTreeIdentifier -> dataTreeIdentifier.contains(subtree)),
-                    "Subtree {} is not controlled by this producer {}", subtree, this);
+                    "Subtree %s is not controlled by this producer %s", subtree, this);
 
             final DOMDataTreePrefixTableEntry<DOMDataTreeShardRegistration<DOMDataTreeShard>> lookup =
                     shardTable.lookup(subtree);
-            Preconditions.checkState(lookup != null, "Subtree {} is not contained in any registered shard.");
+            Preconditions.checkState(lookup != null, "Subtree %s is not contained in any registered shard.", subtree);
 
             final DOMDataTreeIdentifier lookupId = lookup.getValue().getPrefix();
 
index c7e8ced..df0dbcd 100644 (file)
@@ -334,7 +334,7 @@ public final class PingPongTransactionChain implements DOMTransactionChain {
     synchronized void cancelTransaction(final PingPongTransaction tx, final DOMDataReadWriteTransaction frontendTx) {
         // Attempt to unlock the operation.
         final boolean lockedMatch = LOCKED_UPDATER.compareAndSet(this, tx, null);
-        Verify.verify(lockedMatch, "Cancelling transaction {} collided with locked transaction {}", tx, lockedTx);
+        Verify.verify(lockedMatch, "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();
index 9898ce9..f8a16b6 100644 (file)
@@ -200,7 +200,7 @@ public abstract class AbstractSnapshotBackedTransactionChain<T> extends Transact
         final State localState = state;
 
         do {
-            Preconditions.checkState(!CLOSED.equals(localState), "Transaction chain {} has been closed", this);
+            Preconditions.checkState(!CLOSED.equals(localState), "Transaction chain %s has been closed", this);
 
             if (FAILED.equals(localState)) {
                 LOG.debug("Ignoring user close in failed state");

©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.