From: Chi-Vien Ly Date: Tue, 26 Mar 2013 17:43:28 +0000 (-0700) Subject: Resolving http://bugs.opendaylight.org/show_bug.cgi?id=4 X-Git-Tag: releasepom-0.1.0~627 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=0a980f274122e5b73f40dfb9a85783f3023e08a6 Resolving bugs.opendaylight.org/show_bug.cgi?id=4 Change-Id: I2c468299c67a31f073b18e7cc68d9e4f7d364b41 Signed-off-by: Chi-Vien Ly --- diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/Controller.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/Controller.java index e6289581bd..f183b516de 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/Controller.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/Controller.java @@ -154,7 +154,6 @@ public class Controller implements IController, CommandProvider { * */ public void stop() { - for (Iterator> it = switches.entrySet().iterator(); it .hasNext();) { Entry entry = it.next(); @@ -162,7 +161,11 @@ public class Controller implements IController, CommandProvider { it.remove(); } switchEventThread.interrupt(); - controllerIO.shutDown(); + try { + controllerIO.shutDown(); + } catch (IOException ex) { + logger.error("Caught exception: " + ex + " during stop"); + } } /** @@ -227,8 +230,6 @@ public class Controller implements IController, CommandProvider { switchHandler.start(); logger.info(instanceName + " connected: " + sc.toString()); } catch (IOException e) { - logger - .error("Caught I/O Exception when trying to accept a new connection"); return; } } diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/ControllerIO.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/ControllerIO.java index e1bc2d0c14..3e39ab26e6 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/ControllerIO.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/ControllerIO.java @@ -76,9 +76,8 @@ public class ControllerIO { serverSelectionKey); } } - } catch (IOException e) { - logger.error("Caught I/O Exception: " + e.toString()); - return; + } catch (Exception e) { + continue; } } } @@ -87,13 +86,9 @@ public class ControllerIO { logger.info("Controller is now listening on port " + openFlowPort); } - public void shutDown() { + public void shutDown() throws IOException { this.running = false; this.selector.wakeup(); - try { - this.serverSocket.close(); - } catch (IOException e) { - e.printStackTrace(); - } + this.serverSocket.close(); } } 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 c4a85c0091..6d94703182 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,6 @@ package org.opendaylight.controller.protocol_plugin.openflow.core.internal; -import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; @@ -172,9 +171,8 @@ public class SwitchHandler implements ISwitch { handleMessages(); } } - } catch (IOException e) { - logger.error("Caught I/O Exception: " + e.toString()); - e.printStackTrace(); + } catch (Exception e) { + reportError(e); } } } @@ -190,8 +188,9 @@ public class SwitchHandler implements ISwitch { this.clientSelectionKey.cancel(); this.socket.close(); executor.shutdown(); - } catch (IOException e) { - logger.error("Caught IOException in stop()"); + } catch (Exception e) { + // do nothing since we are shutting down. + return; } } @@ -235,7 +234,7 @@ public class SwitchHandler implements ISwitch { this.selector, SelectionKey.OP_WRITE, this); } logger.trace("Message sent: " + msg.toString()); - } catch (IOException e) { + } catch (Exception e) { reportError(e); } } @@ -255,7 +254,7 @@ public class SwitchHandler implements ISwitch { this.clientSelectionKey = this.socket.register( this.selector, SelectionKey.OP_READ, this); } - } catch (IOException e) { + } catch (Exception e) { reportError(e); } } @@ -358,7 +357,7 @@ public class SwitchHandler implements ISwitch { int bytesRead; try { bytesRead = socket.read(inBuffer); - } catch (IOException e) { + } catch (Exception e) { reportError(e); return null; }