Resolving http://bugs.opendaylight.org/show_bug.cgi?id=4 75/75/1
authorChi-Vien Ly <chivly@cisco.com>
Tue, 26 Mar 2013 17:43:28 +0000 (10:43 -0700)
committerChi-Vien Ly <chivly@cisco.com>
Tue, 26 Mar 2013 17:43:28 +0000 (10:43 -0700)
Change-Id: I2c468299c67a31f073b18e7cc68d9e4f7d364b41
Signed-off-by: Chi-Vien Ly <chivly@cisco.com>
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/Controller.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/ControllerIO.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java

index e6289581bded8467ff94b53478be562ae7029025..f183b516de5fb4de0b60a79618664c58108209e1 100644 (file)
@@ -154,7 +154,6 @@ public class Controller implements IController, CommandProvider {
      *
      */
     public void stop() {
-
         for (Iterator<Entry<Long, ISwitch>> it = switches.entrySet().iterator(); it
                 .hasNext();) {
             Entry<Long, ISwitch> 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;
         }
     }
index e1bc2d0c1446a9c6e8b2999f9345a22300b11e62..3e39ab26e6680603391da98b08bef1d82e1df6ba 100644 (file)
@@ -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();
     }
 }
index c4a85c009134c69d12de05f252ac3534da2c1801..6d94703182cf7564be00a60725cab45417046ee0 100644 (file)
@@ -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;
         }