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%2FMessageReadWriteService.java;h=9041004605dded75ce2fe44f129c617656ab6e60;hb=582da55f82ee5d83af2e7a327044c62ef3a76285;hp=d2dab0fc94483b4827890d087c996e0c9ebe3a09;hpb=1757a30c3631e2a5ef97c6b5e79ad2c87fc7d855;p=controller.git diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/MessageReadWriteService.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/MessageReadWriteService.java index d2dab0fc94..9041004605 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/MessageReadWriteService.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/MessageReadWriteService.java @@ -8,7 +8,6 @@ package org.opendaylight.controller.protocol_plugin.openflow.core.internal; -import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.AsynchronousCloseException; import java.nio.channels.ClosedChannelException; @@ -52,13 +51,13 @@ public class MessageReadWriteService implements IMessageReadWrite { /** * Sends the OF message out over the socket channel. - * + * * @param msg * OF message to be sent * @throws Exception */ @Override - public void asyncSend(OFMessage msg) throws IOException { + public void asyncSend(OFMessage msg) throws Exception { synchronized (outBuffer) { int msgLen = msg.getLengthU(); if (outBuffer.remaining() < msgLen) { @@ -90,11 +89,11 @@ public class MessageReadWriteService implements IMessageReadWrite { /** * Resumes sending the remaining messages in the outgoing buffer - * + * * @throws Exception */ @Override - public void resumeSend() throws IOException { + public void resumeSend() throws Exception { synchronized (outBuffer) { if (!socket.isOpen()) { return; @@ -116,12 +115,12 @@ public class MessageReadWriteService implements IMessageReadWrite { /** * Reads the incoming network data from the socket and retrieves the OF * messages. - * + * * @return list of OF messages * @throws Exception */ @Override - public List readMessages() throws IOException { + public List readMessages() throws Exception { if (!socket.isOpen()) { return null; } @@ -133,12 +132,17 @@ public class MessageReadWriteService implements IMessageReadWrite { throw new AsynchronousCloseException(); } - inBuffer.flip(); - msgs = factory.parseMessages(inBuffer); - if (inBuffer.hasRemaining()) { - inBuffer.compact(); - } else { + try { + inBuffer.flip(); + msgs = factory.parseMessages(inBuffer); + if (inBuffer.hasRemaining()) { + inBuffer.compact(); + } else { + inBuffer.clear(); + } + } catch (Exception e) { inBuffer.clear(); + logger.debug("Caught exception: ", e); } return msgs; }