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 e628958..f183b51 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 e1bc2d0..3e39ab2 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 c4a85c0..6d94703 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;
         }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.