Fix Logger use 70/20570/2
authorRobert Varga <rovarga@cisco.com>
Fri, 15 May 2015 20:33:45 +0000 (22:33 +0200)
committerRobert Varga <rovarga@cisco.com>
Fri, 15 May 2015 23:20:38 +0000 (01:20 +0200)
Cleanup use of Loggers so we do not concatenate strings, and also check
if the logging leve is enabled before embarking on creating large
strings.

Change-Id: I9f0f513f8cd4857ab7064ed5b824a01b026b831f
Signed-off-by: Robert Varga <rovarga@cisco.com>
22 files changed:
openflow-protocol-api/pom.xml
openflow-protocol-impl/pom.xml
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java
openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java
openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientFramer.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientFramer.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java

index faf463acad0a8dca27c08f4062221394eee2e706..34c9e9c0618928f54f008f8f736b83e880ffbc68 100644 (file)
@@ -65,7 +65,6 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-antrun-plugin</artifactId>
-                <version>1.7</version>
                 <executions>
                     <execution>
                         <phase>prepare-package</phase>
index 23d0e9fb4372ab86fed99958a85ed4f684ac30a2..ec72b1d8ea2795fbe5972b2fc0d57f544d8eb19f 100644 (file)
@@ -81,7 +81,6 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-jar-plugin</artifactId>
-                <version>2.5</version>
                 <executions>
                     <execution>
                         <goals>
index 670f552c64c10f0c811569c69d289eb36813ce1b..3a083eeac410d74c943bcd3e80c8c8065e86c290 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.openflowjava.protocol.impl.core;
 
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.SimpleChannelInboundHandler;
-
 import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
@@ -28,15 +27,15 @@ public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler<Version
     private DeserializationFactory deserializationFactory;
 
     @Override
-    public void channelRead0(ChannelHandlerContext ctx, VersionMessageUdpWrapper msg)
+    public void channelRead0(final ChannelHandlerContext ctx, final VersionMessageUdpWrapper msg)
             throws Exception {
         if (LOGGER.isDebugEnabled()) {
                 LOGGER.debug("UdpVersionMessageWrapper received");
-                LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
+                LOGGER.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
         }
-        DataObject dataObject = null;
+
         try {
-            dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),msg.getVersion());
+            final DataObject dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),msg.getVersion());
             if (dataObject == null) {
                 LOGGER.warn("Translated POJO is null");
             } else {
@@ -44,8 +43,7 @@ public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler<Version
                 consumer.consume(dataObject);
             }
         } catch(Exception e) {
-            LOGGER.warn("Message deserialization failed");
-            LOGGER.warn(e.getMessage(), e);
+            LOGGER.warn("Message deserialization failed", e);
             // TODO: delegate exception to allow easier deserialization
             // debugging / deserialization problem awareness
         } finally {
@@ -56,7 +54,7 @@ public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler<Version
     /**
      * @param deserializationFactory
      */
-    public void setDeserializationFactory(DeserializationFactory deserializationFactory) {
+    public void setDeserializationFactory(final DeserializationFactory deserializationFactory) {
         this.deserializationFactory = deserializationFactory;
     }
-}
\ No newline at end of file
+}
index 685985ec236178cf9475adb0d4d4a05afff15b3f..ff80584032113987f10e92e97926cd96adc5d063 100644 (file)
@@ -71,8 +71,8 @@ public class OFDatagramPacketHandler extends MessageToMessageDecoder<DatagramPac
         int readableBytes = bb.readableBytes();
         if (readableBytes < LENGTH_OF_HEADER) {
             if (LOGGER.isDebugEnabled()) {
-                LOGGER.debug("skipping bytebuf - too few bytes for header: " + readableBytes + " < " + LENGTH_OF_HEADER );
-                LOGGER.debug("bb: " + ByteBufUtils.byteBufToHexString(bb));
+                LOGGER.debug("skipping bytebuf - too few bytes for header: {} < {}", readableBytes, LENGTH_OF_HEADER);
+                LOGGER.debug("bb: {}", ByteBufUtils.byteBufToHexString(bb));
             }
             return;
         }
@@ -82,9 +82,8 @@ public class OFDatagramPacketHandler extends MessageToMessageDecoder<DatagramPac
 
         if (readableBytes < length) {
             if (LOGGER.isDebugEnabled()) {
-                LOGGER.debug("skipping bytebuf - too few bytes for msg: " +
-                        readableBytes + " < " + length);
-                LOGGER.debug("bytebuffer: " + ByteBufUtils.byteBufToHexString(bb));
+                LOGGER.debug("skipping bytebuf - too few bytes for msg: {} < {}", readableBytes, length);
+                LOGGER.debug("bytebuffer: {}", ByteBufUtils.byteBufToHexString(bb));
             }
             return;
         }
@@ -93,13 +92,13 @@ public class OFDatagramPacketHandler extends MessageToMessageDecoder<DatagramPac
 
         byte version = bb.readByte();
         if ((version == EncodeConstants.OF13_VERSION_ID) || (version == EncodeConstants.OF10_VERSION_ID)) {
-            LOGGER.debug("detected version: " + version);
+            LOGGER.debug("detected version: {}", version);
             ByteBuf messageBuffer = bb.slice();
             out.add(new VersionMessageUdpWrapper(version, messageBuffer, msg.sender()));
             messageBuffer.retain();
         } else {
-            LOGGER.warn("detected version: " + version + " - currently not supported");
+            LOGGER.warn("detected version: {} - currently not supported", version);
         }
         bb.skipBytes(bb.readableBytes());
     }
-}
\ No newline at end of file
+}
index 386caa3442c85b7469f913644146c00db9a9390b..de419f8b005e8d82e8507498ae9c5c525b797eee 100644 (file)
@@ -28,13 +28,17 @@ import org.slf4j.LoggerFactory;
 public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(OFDecoder.class);
+    private final StatisticsCounters statisticsCounter;
+
+    // TODO: make this final?
     private DeserializationFactory deserializationFactory;
-    private StatisticsCounters statisticsCounter;
+
     /**
      * Constructor of class
      */
     public OFDecoder() {
         LOGGER.trace("Creating OF 1.3 Decoder");
+       // TODO: pass as argument
         statisticsCounter = StatisticsCounters.getInstance();
     }
 
@@ -44,12 +48,11 @@ public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
         statisticsCounter.incrementCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA);
         if (LOGGER.isDebugEnabled()) {
             LOGGER.debug("VersionMessageWrapper received");
-            LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
+            LOGGER.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
         }
 
-        DataObject dataObject = null;
         try {
-            dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),
+            final DataObject dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),
                     msg.getVersion());
             if (dataObject == null) {
                 LOGGER.warn("Translated POJO is null");
@@ -58,9 +61,8 @@ public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
                 out.add(dataObject);
                 statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_SUCCESS);
             }
-        } catch(Exception e) {
-            LOGGER.warn("Message deserialization failed");
-            LOGGER.warn(e.getMessage(), e);
+        } catch (Exception e) {
+            LOGGER.warn("Message deserialization failed", e);
             statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_FAIL);
         } finally {
             msg.getMessageBuffer().release();
index 5c3b76167d70d5030ddfdf221a7c1f3340e90f79..f4ec88255fc180dd3784cc118d2550acc83eab6b 100644 (file)
@@ -67,8 +67,8 @@ public class OFFrameDecoder extends ByteToMessageDecoder {
         int readableBytes = bb.readableBytes();
         if (readableBytes < LENGTH_OF_HEADER) {
             if (LOGGER.isDebugEnabled()) {
-                LOGGER.debug("skipping bytebuf - too few bytes for header: " + readableBytes + " < " + LENGTH_OF_HEADER );
-                LOGGER.debug("bb: " + ByteBufUtils.byteBufToHexString(bb));
+                LOGGER.debug("skipping bytebuf - too few bytes for header: {} < {}", readableBytes, LENGTH_OF_HEADER);
+                LOGGER.debug("bb: {}", ByteBufUtils.byteBufToHexString(bb));
             }
             return;
         }
@@ -78,9 +78,8 @@ public class OFFrameDecoder extends ByteToMessageDecoder {
 
         if (readableBytes < length) {
             if (LOGGER.isDebugEnabled()) {
-                LOGGER.debug("skipping bytebuf - too few bytes for msg: " +
-                        readableBytes + " < " + length);
-                LOGGER.debug("bytebuffer: " + ByteBufUtils.byteBufToHexString(bb));
+                LOGGER.debug("skipping bytebuf - too few bytes for msg: {} < {}", readableBytes, length);
+                LOGGER.debug("bytebuffer: {}", ByteBufUtils.byteBufToHexString(bb));
             }
             return;
         }
index 8282f078e7b38b8738b24a62709411659490e437..43277eaa79bd8ba11574db4babffb58107b8e9be 100644 (file)
@@ -58,8 +58,8 @@ public class TcpChannelInitializer extends ProtocolChannelInitializer<SocketChan
             InetAddress switchAddress = ch.remoteAddress().getAddress();
             int port = ch.localAddress().getPort();
             int remotePort = ch.remoteAddress().getPort();
-            LOGGER.debug("Incoming connection from (remote address): " + switchAddress.toString()
-                    + ":" + remotePort + " --> :" + port);
+            LOGGER.debug("Incoming connection from (remote address): {}:{} --> :{}",
+                           switchAddress.toString(), remotePort, port);
 
             if (!getSwitchConnectionHandler().accept(switchAddress)) {
                 ch.disconnect();
@@ -72,7 +72,7 @@ public class TcpChannelInitializer extends ProtocolChannelInitializer<SocketChan
         ConnectionFacade connectionFacade = null;
         connectionFacade = connectionAdapterFactory.createConnectionFacade(ch, null);
         try {
-            LOGGER.debug("calling plugin: " + getSwitchConnectionHandler());
+            LOGGER.debug("calling plugin: {}", getSwitchConnectionHandler());
             getSwitchConnectionHandler().onSwitchConnected(connectionFacade);
             connectionFacade.checkListeners();
             ch.pipeline().addLast(PipelineHandlers.IDLE_HANDLER.name(), new IdleHandler(getSwitchIdleTimeout(), TimeUnit.MILLISECONDS));
@@ -119,4 +119,4 @@ public class TcpChannelInitializer extends ProtocolChannelInitializer<SocketChan
     public int size() {
         return allChannels.size();
     }
-}
\ No newline at end of file
+}
index 0ee3fb281ea6dec2204b4c82d1bb8634cd2048a7..3479bcc01d6c70dad3b8f6fe88f88d5601cacf7c 100644 (file)
@@ -75,9 +75,8 @@ public class DeserializerRegistryImpl implements DeserializerRegistry {
         }
         OFGeneralDeserializer desInRegistry = registry.put(key, deserializer);
         if (desInRegistry != null) {
-            LOGGER.debug("Deserializer for key " + key + " overwritten. Old deserializer: "
-                    + desInRegistry.getClass().getName() + ", new deserializer: "
-                    + deserializer.getClass().getName() );
+            LOGGER.debug("Deserializer for key {} overwritten. Old deserializer: {}, new deserializer: {}",
+                    key, desInRegistry.getClass().getName(), deserializer.getClass().getName());
         }
         if (deserializer instanceof DeserializerRegistryInjector) {
             ((DeserializerRegistryInjector) deserializer).injectDeserializerRegistry(this);
index 9a4c20859c92589382202afcf9f02da4064a1dbe..5756352c7c579b2cb4bc8ed2519c568464afbcfb 100644 (file)
@@ -81,9 +81,8 @@ public class SerializerRegistryImpl implements SerializerRegistry {
         }
         OFGeneralSerializer serInRegistry = registry.put(msgTypeKey, serializer);
         if (serInRegistry != null) {
-            LOGGER.debug("Serializer for key " + msgTypeKey + " overwritten. Old serializer: "
-                    + serInRegistry.getClass().getName() + ", new serializer: "
-                    + serializer.getClass().getName() );
+            LOGGER.debug("Serializer for key {} overwritten. Old serializer: {}, new serializer: {}",
+                    msgTypeKey, serInRegistry.getClass().getName(), serializer.getClass().getName());
         }
         if (serializer instanceof SerializerRegistryInjector) {
             ((SerializerRegistryInjector) serializer).injectSerializerRegistry(this);
index b84d81cfd8ee28c4377db3d906016ee9b3322a6f..c96465852a6085e343a84ffc44a85f571780d45c 100644 (file)
@@ -7,11 +7,8 @@
  */
 package org.opendaylight.openflowjava.protocol.impl.serialization.match;
 
-import io.netty.buffer.ByteBuf;
-
-import org.opendaylight.openflowjava.util.ByteBufUtils;
-
 import com.google.common.net.InetAddresses;
+import io.netty.buffer.ByteBuf;
 
 /**
  * Parent for Ipv6 address based match entry serializers
@@ -19,7 +16,7 @@ import com.google.common.net.InetAddresses;
  */
 public abstract class AbstractOxmIpv6AddressSerializer extends AbstractOxmMatchEntrySerializer {
 
-    protected void writeIpv6Address(String textAddress, final ByteBuf outBuffer) {
+    protected void writeIpv6Address(final String textAddress, final ByteBuf outBuffer) {
         if (InetAddresses.isInetAddress(textAddress)) {
             byte[] binaryAddress = InetAddresses.forString(textAddress).getAddress();
             outBuffer.writeBytes(binaryAddress);
index c383532467b166604323a8b20a5d5da3c99d04da..d947b3fdf068eb8e0c86f3fc2f128130ef14f33a 100644 (file)
@@ -84,7 +84,9 @@ public class HelloInputMessageFactoryTest {
 
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
         helloFactory.serialize(message, out);
-        LOGGER.debug("bytebuf: " + ByteBufUtils.byteBufToHexString(out));
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("bytebuf: {}", ByteBufUtils.byteBufToHexString(out));
+        }
 
         BufferHelper.checkHeaderV13(out, (byte) 0, 16);
         Elements element = readElement(out).get(0);
@@ -108,7 +110,9 @@ public class HelloInputMessageFactoryTest {
 
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
         helloFactory.serialize(message, out);
-        LOGGER.debug("bytebuf: " + ByteBufUtils.byteBufToHexString(out));
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("bytebuf: ", ByteBufUtils.byteBufToHexString(out));
+        }
 
         BufferHelper.checkHeaderV13(out, (byte) 0, 24);
         Elements element = readElement(out).get(0);
@@ -142,7 +146,7 @@ public class HelloInputMessageFactoryTest {
                 booleanList.add(false);
             }
         }
-        LOGGER.debug("boolsize " + booleanList.size());
+        LOGGER.debug("boolsize {}", booleanList.size());
         elementsBuilder.setType(HelloElementType.forValue(1));
         elementsBuilder.setVersionBitmap(booleanList);
         elementsList.add(elementsBuilder.build());
index 63af21696a05a1f690e7ebbfca4822d6f8731e09..76fe9888a5ccfe9469eb046022553e5cc798b7d9 100644 (file)
@@ -82,7 +82,7 @@ public class ActionsDeserializerTest {
                 + "00 1B 00 08 00 00 00 00");
 
         message.skipBytes(4); // skip XID
-        LOGGER.info("bytes: " + message.readableBytes());
+        LOGGER.info("bytes: {}", message.readableBytes());
 
         CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
         List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID,
index 3eedff52d3720b418da8424df562d1bdb32825f0..54ccb37ef816968e143b6d01c6c96de65b5eecf1 100644 (file)
@@ -69,7 +69,7 @@ public class IntegrationTest {
         LOGGER.debug("\n starting test -------------------------------");
 
         String currentDir = System.getProperty("user.dir");
-        LOGGER.debug("Current dir using System:" +currentDir);
+        LOGGER.debug("Current dir using System: {}", currentDir);
         startupAddress = InetAddress.getLocalHost();
         tlsConfiguration = null;
         if (protocol.equals(TransportProtocol.TLS)) {
@@ -221,7 +221,7 @@ public class IntegrationTest {
             TransportProtocol protocol, ClientType clientType) throws ExecutionException {
         List<OFClient> clientsHorde = new ArrayList<>();
         for (int i = 0; i < amountOfCLients; i++) {
-            LOGGER.debug("startup address in createclient: " + startupAddress.getHostAddress());
+            LOGGER.debug("startup address in createclient: {}", startupAddress.getHostAddress());
             OFClient sc = null;
             if (clientType == ClientType.SIMPLE) {
                 if (protocol.equals(TransportProtocol.TCP)) {
index f09da22c4dc7bd4b5d7d3aa397e055252bdd5aa3..dadfa73c1907b91ed3472218e002bacf03ca3b27 100644 (file)
@@ -61,12 +61,12 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
     public MockPlugin() {
         LOGGER.trace("Creating MockPlugin");
         finishedFuture = SettableFuture.create();
-        LOGGER.debug("mockPlugin: "+System.identityHashCode(this));
+        LOGGER.debug("mockPlugin: {}", System.identityHashCode(this));
     }
 
     @Override
     public void onSwitchConnected(ConnectionAdapter connection) {
-        LOGGER.debug("onSwitchConnected: " + connection);
+        LOGGER.debug("onSwitchConnected: {}", connection);
         this.adapter = connection;
         connection.setMessageListener(this);
         connection.setSystemListener(this);
@@ -75,25 +75,25 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
 
     @Override
     public boolean accept(InetAddress switchAddress) {
-        LOGGER.debug("MockPlugin.accept(): " + switchAddress.toString());
+        LOGGER.debug("MockPlugin.accept(): {}", switchAddress.toString());
 
         return true;
     }
 
     @Override
     public void onEchoRequestMessage(final EchoRequestMessage notification) {
-        LOGGER.debug("MockPlugin.onEchoRequestMessage() adapter: "+adapter);
+        LOGGER.debug("MockPlugin.onEchoRequestMessage() adapter: {}", adapter);
         new Thread(new Runnable() {
             @Override
             public void run() {
-                LOGGER.debug("MockPlugin.onEchoRequestMessage().run() started adapter: "+adapter);
+                LOGGER.debug("MockPlugin.onEchoRequestMessage().run() started adapter: {}", adapter);
                 EchoReplyInputBuilder replyBuilder = new EchoReplyInputBuilder();
                 replyBuilder.setVersion((short) 4);
                 replyBuilder.setXid(notification.getXid());
                 EchoReplyInput echoReplyInput = replyBuilder.build();
                 adapter.echoReply(echoReplyInput);
                 LOGGER.debug("adapter.EchoReply(Input) sent : ", echoReplyInput.toString());
-                LOGGER.debug("MockPlugin.onEchoRequestMessage().run() finished adapter: "+adapter);
+                LOGGER.debug("MockPlugin.onEchoRequestMessage().run() finished adapter: {}", adapter);
             }
         }).start();
     }
@@ -151,11 +151,10 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
             if (rpcResult.isSuccessful()) {
                 byte[] byteArray = rpcResult.getResult().getDatapathId()
                         .toByteArray();
-                LOGGER.debug("DatapathId: " + Arrays.toString(byteArray));
+                LOGGER.debug("DatapathId: {}", Arrays.toString(byteArray));
             } else {
                 RpcError rpcError = rpcResult.getErrors().iterator().next();
-                LOGGER.warn("rpcResult failed: "
-                        + rpcError.getCause().getMessage(), rpcError.getCause());
+                LOGGER.warn("rpcResult failed", rpcError.getCause());
             }
         } catch (InterruptedException | ExecutionException | TimeoutException e) {
             LOGGER.error("getSwitchFeatures() exception caught: ", e.getMessage(), e);
@@ -164,7 +163,7 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
 
     protected void shutdown() {
         try {
-            LOGGER.debug("MockPlugin.shutdown() sleeping 5... : "+System.identityHashCode(this));
+            LOGGER.debug("MockPlugin.shutdown() sleeping 5... : {}", System.identityHashCode(this));
             Thread.sleep(500);
             if (adapter != null) {
                 Future<Boolean> disconnect = adapter.disconnect();
@@ -186,14 +185,14 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
     @Override
     public void onPacketInMessage(PacketInMessage notification) {
         LOGGER.debug("PacketIn message received");
-        LOGGER.debug("BufferId: " + notification.getBufferId());
-        LOGGER.debug("TotalLength: " + notification.getTotalLen());
-        LOGGER.debug("Reason: " + notification.getReason());
-        LOGGER.debug("TableId: " + notification.getTableId());
-        LOGGER.debug("Cookie: " + notification.getCookie());
-        LOGGER.debug("Class: " + notification.getMatch().getMatchEntry().get(0).getOxmClass());
-        LOGGER.debug("Field: " + notification.getMatch().getMatchEntry().get(0).getOxmMatchField());
-        LOGGER.debug("Datasize: " + notification.getData().length);
+        LOGGER.debug("BufferId: {}", notification.getBufferId());
+        LOGGER.debug("TotalLength: {}", notification.getTotalLen());
+        LOGGER.debug("Reason: {}", notification.getReason());
+        LOGGER.debug("TableId: {}", notification.getTableId());
+        LOGGER.debug("Cookie: {}", notification.getCookie());
+        LOGGER.debug("Class: {}", notification.getMatch().getMatchEntry().get(0).getOxmClass());
+        LOGGER.debug("Field: {}", notification.getMatch().getMatchEntry().get(0).getOxmMatchField());
+        LOGGER.debug("Datasize: {}", notification.getData().length);
     }
 
     @Override
@@ -204,7 +203,7 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
 
     @Override
     public void onDisconnectEvent(DisconnectEvent notification) {
-        LOGGER.debug("disconnection occured: "+notification.getInfo());
+        LOGGER.debug("disconnection occured: {}", notification.getInfo());
     }
 
     /**
@@ -216,7 +215,7 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
 
     @Override
     public void onSwitchIdleEvent(SwitchIdleEvent notification) {
-        LOGGER.debug("MockPlugin.onSwitchIdleEvent() switch status: "+notification.getInfo());
+        LOGGER.debug("MockPlugin.onSwitchIdleEvent() switch status: {}", notification.getInfo());
         idleCounter ++;
     }
 
index b7cf3de0b44051b00521ac3fa3d92694bed1f4fb..57865d88601b10b333e51c538c7a83cc08746ee5 100644 (file)
@@ -45,7 +45,7 @@ public class ScenarioHandler extends Thread {
     public void run() {
         int freezeCounter = 0;
         while (!scenario.isEmpty()) {
-            LOGGER.debug("Running event #" + eventNumber);
+            LOGGER.debug("Running event #{}", eventNumber);
             ClientEvent peek = scenario.peekLast();
             if (peek instanceof WaitForMessageEvent) {
                 LOGGER.debug("WaitForMessageEvent");
@@ -69,7 +69,7 @@ public class ScenarioHandler extends Thread {
                 freezeCounter++;
             }
             if (freezeCounter > 2) {
-                LOGGER.warn("Scenario freezed: " + freezeCounter);
+                LOGGER.warn("Scenario frozen: {}", freezeCounter);
                 break;
             }
             try {
index c57652724a03d3c3a012d99eec1043c1fac4b7c0..3f456d12cdece4467ca86c354a3c63a99d142344 100644 (file)
@@ -43,8 +43,11 @@ public class SendEvent implements ClientEvent {
         ByteBuf buffer = ctx.alloc().buffer();
         buffer.writeBytes(msgToSend);
         ctx.writeAndFlush(buffer);
-        LOGGER.debug(">> " + ByteBufUtils.bytesToHexString(msgToSend));
-        LOGGER.debug("message sent");
+
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug(">> {}", ByteBufUtils.bytesToHexString(msgToSend));
+            LOGGER.debug("message sent");
+        }
         return true;
     }
 
index b097b1d16cf8f422f0b9b6e1a485a5f791a02d60..5e98e3d601ad5c7d9ed731b48ba0d37a15dbe549 100644 (file)
@@ -115,8 +115,7 @@ public class SimpleClient implements OFClient {
         int port;
         SimpleClient sc;
         if (args.length != 3) {
-            LOGGER.error("Usage: " + SimpleClient.class.getSimpleName()
-                    + " <host> <port> <secured>");
+            LOGGER.error("Usage: {} <host> <port> <secured>", SimpleClient.class.getSimpleName());
             LOGGER.error("Trying to use default setting.");
             InetAddress ia = InetAddress.getLocalHost();
             InetAddress[] all = InetAddress.getAllByName(ia.getHostName());
@@ -147,4 +146,4 @@ public class SimpleClient implements OFClient {
     public void setScenarioHandler(ScenarioHandler scenario) {
         this.scenarioHandler = scenario;
     }
-}
\ No newline at end of file
+}
index a1ade5570058e24389d896e3d83b1b9f20ec1342..1420ad8d023a68599a1ff293788e3197daba3458 100644 (file)
@@ -46,14 +46,13 @@ public class SimpleClientFramer extends ByteToMessageDecoder {
     @Override
     protected void decode(ChannelHandlerContext chc, ByteBuf bb, List<Object> list) throws Exception {
         if (bb.readableBytes() < LENGTH_OF_HEADER) {
-            LOGGER.debug("skipping bb - too few data for header: " + bb.readableBytes());
+            LOGGER.debug("skipping bb - too few data for header: {}", bb.readableBytes());
             return;
         }
 
         int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER);
         if (bb.readableBytes() < length) {
-            LOGGER.debug("skipping bb - too few data for msg: " +
-                    bb.readableBytes() + " < " + length);
+            LOGGER.debug("skipping bb - too few data for msg: {} < {}", bb.readableBytes(), length);
             return;
         }
         LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1));
index 01e114bf15aabbbd5281e1131a121c464af9b6c6..acc538340d9115190fa17eeb45ddabf67ddf55c0 100644 (file)
@@ -43,7 +43,7 @@ public class SimpleClientHandler extends ChannelInboundHandlerAdapter {
     public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
         ByteBuf bb = (ByteBuf) msg;
         if (LOGGER.isDebugEnabled()) {
-            LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(bb));
+            LOGGER.debug("<< {}", ByteBufUtils.byteBufToHexString(bb));
         }
         int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER);
         LOGGER.trace("SimpleClientHandler - start of read");
index e9d69da1224d056312f442eeb9e5ae46dadf34bb..e9d4644e174079273f528619b1a84214ddb63588 100644 (file)
@@ -111,8 +111,7 @@ public class UdpSimpleClient implements OFClient {
         int port;
         UdpSimpleClient sc;
         if (args.length != 2) {
-            LOGGER.error("Usage: " + UdpSimpleClient.class.getSimpleName()
-                    + " <host> <port>");
+            LOGGER.error("Usage: {} <host> <port>", UdpSimpleClient.class.getSimpleName());
             LOGGER.error("Trying to use default setting.");
             InetAddress ia = InetAddress.getLocalHost();
             InetAddress[] all = InetAddress.getAllByName(ia.getHostName());
@@ -147,4 +146,4 @@ public class UdpSimpleClient implements OFClient {
     public void setSecuredClient(boolean securedClient) {
         // TODO: Finish implementation when DTLS is supported
     }
-}
\ No newline at end of file
+}
index d5f8e7beeb37bebca5eba1f407b5560a0ad163f1..be73d27c8d224ffffbdd75f820c27e251d359b96 100644 (file)
@@ -48,14 +48,13 @@ public class UdpSimpleClientFramer extends MessageToMessageDecoder<DatagramPacke
     protected void decode(ChannelHandlerContext chc, DatagramPacket msg, List<Object> list) throws Exception {
         ByteBuf bb = msg.content();
         if (bb.readableBytes() < LENGTH_OF_HEADER) {
-            LOGGER.debug("skipping bb - too few data for header: " + bb.readableBytes());
+            LOGGER.debug("skipping bb - too few data for header: {}", bb.readableBytes());
             return;
         }
 
         int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER);
         if (bb.readableBytes() < length) {
-            LOGGER.debug("skipping bb - too few data for msg: " +
-                    bb.readableBytes() + " < " + length);
+            LOGGER.debug("skipping bb - too few data for msg: {} < {}", bb.readableBytes(), length);
             return;
         }
         LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1));
@@ -65,4 +64,4 @@ public class UdpSimpleClientFramer extends MessageToMessageDecoder<DatagramPacke
         messageBuffer.retain();
         bb.skipBytes(length);
     }
-}
\ No newline at end of file
+}
index bcf696e95b6e3b96d5ae60dca71e2e0be6d2dabe..b448111a85e7a74af188462091945cfdea36ac1a 100644 (file)
@@ -40,8 +40,10 @@ public class WaitForMessageEvent implements ClientEvent {
             return false;
         }
         if (!Arrays.equals(headerExpected, headerReceived)) {
-            LOGGER.debug("expected msg: " + ByteBufUtils.bytesToHexString(headerExpected));
-            LOGGER.debug("received msg: " + ByteBufUtils.bytesToHexString(headerReceived));
+            if (LOGGER.isDebugEnabled()) {
+                LOGGER.debug("expected msg: {}", ByteBufUtils.bytesToHexString(headerExpected));
+                LOGGER.debug("received msg: {}", ByteBufUtils.bytesToHexString(headerReceived));
+            }
             return false;
         }
         LOGGER.debug("Headers OK");