Do not use Foo.toString() when logging 00/85400/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 28 Oct 2019 07:25:36 +0000 (08:25 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 28 Oct 2019 07:25:36 +0000 (08:25 +0100)
This was spotted in a JFR run, where JsonRpcEndpoint would consume
a lot of CPU formatting a logging object. Eliminate calls to toString()
in logging arguments, as the framework will call these when really
needed.

Change-Id: Id077c285074c1fd8012539ab7c144ddc4b286376
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
hwvtepsouthbound/hwvtepsouthbound-it/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/it/HwvtepSouthboundIT.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/jsonrpc/JsonRpcEndpoint.java
library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestIT.java
library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestTypedIT.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbAutoAttachRemovedCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbQosRemovedCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbQueueRemovedCommand.java
southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/SouthboundIT.java

index 96b1bb6e8012f68b841009676b43c3c5fabb9750..2513237e0867b3c2e99b395d2c8c16642057a7de 100644 (file)
@@ -425,7 +425,7 @@ public class HwvtepSouthboundIT extends AbstractMdsalTestBase {
             psAugBuilder.setTunnelIps(tunnelIps);
             psAugBuilder.setTunnels(tunnels);
             psNodeBuilder.addAugmentation(PhysicalSwitchAugmentation.class, psAugBuilder.build());
-            LOG.debug("Built with intent to store PhysicalSwitch data {}", psAugBuilder.toString());
+            LOG.debug("Built with intent to store PhysicalSwitch data {}", psAugBuilder);
             Assert.assertTrue(
                     mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, psIid, psNodeBuilder.build()));
             try {
index 3be844912705c0a85f535f70d0bd6e55460dac96..0edbd65a6ffb0293c6920d42323b38b5c4985fd8 100644 (file)
@@ -509,7 +509,7 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
     }
 
     public static void channelClosed(final OvsdbClient client) {
-        LOG.info("Connection closed {}", client.getConnectionInfo().toString());
+        LOG.info("Connection closed {}", client.getConnectionInfo());
         CONNECTIONS.remove(client);
         if (client.isConnectionPublished()) {
             for (OvsdbConnectionListener listener : CONNECTION_LISTENERS) {
index 39c6474bb0fcff2b154fb1b11206a4341cb2306c..4922ac34efa6e158f187a59acea8ba9382497a10 100644 (file)
@@ -138,7 +138,7 @@ public class JsonRpcEndpoint {
 
     public void processResult(JsonNode response) throws NoSuchMethodException {
 
-        LOG.trace("Response : {}", response.toString());
+        LOG.trace("Response : {}", response);
         CallContext returnCtxt = methodContext.remove(response.get("id").asText());
         if (returnCtxt == null) {
             return;
@@ -154,7 +154,7 @@ public class JsonRpcEndpoint {
             Object result1 = objectMapper.convertValue(result, javaType);
             JsonNode error = response.get("error");
             if (error != null && !error.isNull()) {
-                LOG.error("Error : {}", error.toString());
+                LOG.error("Error : {}", error);
             }
 
             returnCtxt.getFuture().set(result1);
@@ -216,7 +216,7 @@ public class JsonRpcEndpoint {
             return;
         }
 
-        LOG.error("No handler for Request : {} on {}", requestJson.toString(), context);
+        LOG.error("No handler for Request : {} on {}", requestJson, context);
     }
 
     public Map<String, CallContext> getMethodContext() {
index b45dd96c1dffe1109ed4b9c3508cb6c6978d5121..09c18e1d72a8a79f14e9d88ad3e74d7e63c49678 100644 (file)
@@ -341,7 +341,7 @@ public class OvsdbClientTestIT extends LibraryIntegrationTestBase {
 
         ovs = LibraryIntegrationTestUtils.getTestConnection(this);
         assertNotNull("Failed to get connection to ovsdb node", ovs);
-        LOG.info("Connection Info: {}", ovs.getConnectionInfo().toString());
+        LOG.info("Connection Info: {}", ovs.getConnectionInfo());
         testGetDBs();
         dbSchema = ovs.getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH).get();
     }
index 975e403968d3948b5d13314a1a86522b59144932..af1cdc01ff8b06779520964629bfb028291c8015 100644 (file)
@@ -113,7 +113,7 @@ public class OvsdbClientTestTypedIT extends LibraryIntegrationTestBase {
         }
         ovs = LibraryIntegrationTestUtils.getTestConnection(this);
         assertNotNull("Failed to get connection to ovsdb node", ovs);
-        LOG.info("Connection Info: {}", ovs.getConnectionInfo().toString());
+        LOG.info("Connection Info: {}", ovs.getConnectionInfo());
         testGetDBs();
         dbSchema = ovs.getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH).get();
     }
index ee0a32b7ea91b645ba3fc02fd32abcb9d3b61c17..d420ec8013136eff5bd681dd15cf4ef3d8053bf6 100644 (file)
@@ -60,10 +60,10 @@ public class OvsdbAutoAttachRemovedCommand extends AbstractTransactionCommand {
                             .augmentation(OvsdbNodeAugmentation.class)
                             .child(Autoattach.class, autoAttachKey);
                     transaction.delete(LogicalDatastoreType.OPERATIONAL, iid);
-                    LOG.debug("AutoAttach table {} for Ovsdb Node {} is deleted", autoAttachUuid.toString(),
+                    LOG.debug("AutoAttach table {} for Ovsdb Node {} is deleted", autoAttachUuid,
                             ovsdbNode.get().getNodeId());
                 } else {
-                    LOG.warn("AutoAttach table {} not found for Ovsdb Node {} to delete", autoAttachUuid.toString(),
+                    LOG.warn("AutoAttach table {} not found for Ovsdb Node {} to delete", autoAttachUuid,
                             ovsdbNode.get().getNodeId());
                 }
             }
index 95e8389f362fb852c0b864404414dd7a8de38250..1332226ff62e2450674afa095e3baba28effdf48 100644 (file)
@@ -71,7 +71,7 @@ public class OvsdbQosRemovedCommand extends AbstractTransactionCommand {
     private QosEntriesKey getQosEntriesKey(Node node, UUID qosUuid) {
         List<QosEntries> qosList = node.augmentation(OvsdbNodeAugmentation.class).getQosEntries();
         if (qosList == null || qosList.isEmpty()) {
-            LOG.debug("Deleting Qos {}, Ovsdb Node {} does not have a Qos list.", qosUuid.toString(), node);
+            LOG.debug("Deleting Qos {}, Ovsdb Node {} does not have a Qos list.", qosUuid, node);
             return null;
         }
         Iterator<QosEntries> itr = qosList.iterator();
@@ -82,7 +82,7 @@ public class OvsdbQosRemovedCommand extends AbstractTransactionCommand {
                 return qos.key();
             }
         }
-        LOG.debug("Deleted Queue {} not found in Ovsdb Node {}", qosUuid.toString(), node);
+        LOG.debug("Deleted Queue {} not found in Ovsdb Node {}", qosUuid, node);
         return null;
     }
 
index a1d0c6805ff1a12dae93278562c7540fa07e3b26..cc0b0dc2b3e797a2b78a659b632b498592536fd4 100644 (file)
@@ -71,7 +71,7 @@ public class OvsdbQueueRemovedCommand extends AbstractTransactionCommand {
     private QueuesKey getQueueKey(Node node, UUID queueUuid) {
         List<Queues> queueList = node.augmentation(OvsdbNodeAugmentation.class).getQueues();
         if (queueList == null || queueList.isEmpty()) {
-            LOG.debug("Deleting Queue {}, Ovsdb Node {} does not have a Queue list.", queueUuid.toString(), node);
+            LOG.debug("Deleting Queue {}, Ovsdb Node {} does not have a Queue list.", queueUuid, node);
             return null;
         }
         Iterator<Queues> itr = queueList.iterator();
@@ -82,7 +82,7 @@ public class OvsdbQueueRemovedCommand extends AbstractTransactionCommand {
                 return queue.key();
             }
         }
-        LOG.debug("Deleted Queue {} not found in Ovsdb Node {}", queueUuid.toString(), node);
+        LOG.debug("Deleted Queue {} not found in Ovsdb Node {}", queueUuid, node);
         return null;
     }
 
index e64f10ee4b698f9831c1d1f62396a40b1cbb6ce1..82e4dd3dd24b8f37b77486491d8ecc464de08920 100644 (file)
@@ -880,7 +880,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
             ovsdbBridgeAugmentationBuilder.setControllerEntry(controllerEntries);
             ovsdbBridgeAugmentationBuilder.setBridgeOtherConfigs(otherConfigs);
             bridgeNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, ovsdbBridgeAugmentationBuilder.build());
-            LOG.debug("Built with the intent to store bridge data {}", ovsdbBridgeAugmentationBuilder.toString());
+            LOG.debug("Built with the intent to store bridge data {}", ovsdbBridgeAugmentationBuilder);
             Assert.assertTrue(
                     mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, bridgeIid, bridgeNodeBuilder.build()));
             try {
@@ -2074,7 +2074,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                 helper.writeValues(bridgeCreateAugmentationBuilder, updateFromTestCase.inputValues);
                 bridgeCreateNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class,
                         bridgeCreateAugmentationBuilder.build());
-                LOG.debug("Built with the intent to store bridge data {}", bridgeCreateAugmentationBuilder.toString());
+                LOG.debug("Built with the intent to store bridge data {}", bridgeCreateAugmentationBuilder);
                 Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, bridgeIid,
                         bridgeCreateNodeBuilder.build()));
                 Thread.sleep(OVSDB_UPDATE_TIMEOUT);