Merge "Removed unused private variable containerAwareRegistration - please review...
[controller.git] / opendaylight / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / core / internal / SwitchHandler.java
index 5c51cc5862d5f4c391cd956c1c8b59e1f03059ce..91606f4a41daaeecd7cce64e0566c54e028ced82 100644 (file)
@@ -207,7 +207,6 @@ public class SwitchHandler implements ISwitch {
         }
         executor.shutdown();
 
-        selector = null;
         msgReadWriteService = null;
 
         if (switchHandlerThread != null) {
@@ -313,19 +312,21 @@ public class SwitchHandler implements ISwitch {
         List<OFMessage> msgs = null;
 
         try {
-            msgs = msgReadWriteService.readMessages();
+            if (msgReadWriteService != null) {
+                msgs = msgReadWriteService.readMessages();
+            }
         } catch (Exception e) {
             reportError(e);
         }
 
         if (msgs == null) {
-            logger.debug("{} is down", toString());
+            logger.debug("{} is down", this);
             // the connection is down, inform core
             reportSwitchStateChange(false);
             return;
         }
         for (OFMessage msg : msgs) {
-            logger.trace("Message received: {}", msg.toString());
+            logger.trace("Message received: {}", msg);
             this.lastMsgReceivedTimeStamp = System.currentTimeMillis();
             OFType type = msg.getType();
             switch (type) {
@@ -417,7 +418,7 @@ public class SwitchHandler implements ISwitch {
                             // send a probe to see if the switch is still alive
                             logger.debug(
                                     "Send idle probe (Echo Request) to {}",
-                                    toString());
+                                    this);
                             probeSent = true;
                             OFMessage echo = factory
                                     .getMessage(OFType.ECHO_REQUEST);
@@ -461,7 +462,9 @@ public class SwitchHandler implements ISwitch {
                 || e instanceof InterruptedException
                 || e instanceof SocketException || e instanceof IOException
                 || e instanceof ClosedSelectorException) {
-            logger.debug("Caught exception {}", e.getMessage());
+            if (logger.isDebugEnabled()) {
+              logger.debug("Caught exception {}", e.getMessage());
+            }
         } else {
             logger.warn("Caught exception ", e);
         }
@@ -728,7 +731,7 @@ public class SwitchHandler implements ISwitch {
                     if (!transmitQ.isEmpty()) {
                         PriorityMessage pmsg = transmitQ.poll();
                         msgReadWriteService.asyncSend(pmsg.msg);
-                        logger.trace("Message sent: {}", pmsg.toString());
+                        logger.trace("Message sent: {}", pmsg);
                         /*
                          * If syncReply is set to true, wait for the response
                          * back.
@@ -882,8 +885,10 @@ public class SwitchHandler implements ISwitch {
                 // if result is not null, this means the switch can't handle
                 // this message
                 // the result if OFError already
-                logger.debug("Send {} failed --> {}", msg.getType().toString(),
-                        ((OFError) result).toString());
+                if (logger.isDebugEnabled()) {
+                  logger.debug("Send {} failed --> {}", msg.getType(),
+                               ((OFError) result));
+                }
             }
             return result;
         } catch (Exception e) {