X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fprotocol_plugins%2Fopenflow%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotocol_plugin%2Fopenflow%2Fcore%2Finternal%2FSwitchHandler.java;h=5913ad0dd960036f3362c5e2325d0af5209529ab;hb=refs%2Fchanges%2F00%2F200%2F1;hp=78ab3275a4ac674333f8b4cb26464b61488d2cda;hpb=a409fe492f53dd811259c11f0cde4f8771f269ad;p=controller.git diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java index 78ab3275a4..5913ad0dd9 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.protocol_plugin.openflow.core.internal; -import java.io.IOException; +import java.net.SocketException; import java.nio.channels.AsynchronousCloseException; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; @@ -249,7 +249,9 @@ public class SwitchHandler implements ISwitch { @Override public Integer asyncSend(OFMessage msg, int xid) { msg.setXid(xid); - transmitQ.add(new PriorityMessage(msg, 0)); + if (transmitQ != null) { + transmitQ.add(new PriorityMessage(msg, 0)); + } return xid; } @@ -280,13 +282,17 @@ public class SwitchHandler implements ISwitch { @Override public Integer asyncFastSend(OFMessage msg, int xid) { msg.setXid(xid); - transmitQ.add(new PriorityMessage(msg, 1)); + if (transmitQ != null) { + transmitQ.add(new PriorityMessage(msg, 1)); + } return xid; } public void resumeSend() { try { - msgReadWriteService.resumeSend(); + if (msgReadWriteService != null) { + msgReadWriteService.resumeSend(); + } } catch (Exception e) { reportError(e); } @@ -445,7 +451,9 @@ public class SwitchHandler implements ISwitch { } private void reportError(Exception e) { - if (e instanceof AsynchronousCloseException) { + if (e instanceof AsynchronousCloseException || + e instanceof InterruptedException || + e instanceof SocketException) { logger.debug("Caught exception {}", e.getMessage()); } else { logger.warn("Caught exception {}", e.getMessage()); @@ -739,6 +747,8 @@ public class SwitchHandler implements ISwitch { logger.trace("Message sent: {}", pmsg.toString()); } Thread.sleep(10); + } catch (InterruptedException ie) { + reportError(new InterruptedException("PriorityMessageTransmit thread interrupted")); } catch (Exception e) { reportError(e); } @@ -781,8 +791,8 @@ public class SwitchHandler implements ISwitch { } private IMessageReadWrite getMessageReadWriteService() throws Exception { - String str = System.getProperty("secureChannelEnabled").trim(); - return ((str != null) && (str.equalsIgnoreCase("true"))) ? + String str = System.getProperty("secureChannelEnabled"); + return ((str != null) && (str.trim().equalsIgnoreCase("true"))) ? new SecureMessageReadWriteService(socket, selector) : new MessageReadWriteService(socket, selector); }