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 97c42803ef618662efacb522244762088eb4f13a..7a1a74e75f26c4f8839e2b0661e9577f89e35590 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 147d6ee36994739f577bad8b144a8627ddaed135..7d0bee25333b84148bfce23e1c09380e169b2149 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 ae047efc251cb59374a4aff00f061bc289a60fb4..6f283f549cbdbdf50c75d99397fd650a2b709897 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 07b89e09230949da6c4849b3fb5dc03d4c3c36d8..2988c391a35aafc08b05fd3ab0e1f5d0fa08725e 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 a1ddcc344953f991b34450d34afb5615bc6c4149..46e035d0ec63ec025d0b78d1260cf519ffc51a15 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 c44e70eb304f4458aeb2d9782b9f9581abcbfa81..77e2a6a6ccd9e2e3085589f6a1a751df537a0245 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 99c03768ed111bff08a9a8d9fbd8bcbd98e739d6..277c09f73069fcf4cfff7ae6659dfb099fb299a1 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 c7e8ced21a4139b6d870dc4de1bb606834f4ad5f..df0dbcd77d90eb0d1b986814d6366b5020e99398 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 9898ce9bb95d24b524497ab12339067514688a74..f8a16b606a341316fde1e2806e07265c5b88c1f9 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");