This is a fix for the latch to countdown in case of exceptions and
[controller.git] / opendaylight / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / core / internal / ControllerIO.java
index e1bc2d0c1446a9c6e8b2999f9345a22300b11e62..868e2086511b5cd7926ccb08275cbda6bb270c9d 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
@@ -35,13 +34,13 @@ public class ControllerIO {
     public ControllerIO(IController l) {
         this.listener = l;
         this.openFlowPort = defaultOpenFlowPort;
-        String portString = System.getProperty("port");
+        String portString = System.getProperty("of.listenPort");
         if (portString != null) {
             try {
                 openFlowPort = Short.decode(portString).shortValue();
             } catch (NumberFormatException e) {
-                logger.warn("Invalid port:" + portString + ", use default("
-                        + openFlowPort + ")");
+                logger.warn("Invalid port:{}, use default({})", portString,
+                        openFlowPort);
             }
         }
     }
@@ -72,28 +71,23 @@ public class ControllerIO {
                             SelectionKey skey = selectedKeys.next();
                             selectedKeys.remove();
                             if (skey.isValid() && skey.isAcceptable()) {
-                                 ((Controller) listener).handleNewConnection(selector,
-                                        serverSelectionKey);
+                                ((Controller) listener).handleNewConnection(
+                                        selector, serverSelectionKey);
                             }
                         }
-                    } catch (IOException e) {
-                        logger.error("Caught I/O Exception: " + e.toString());
-                        return;
+                    } catch (Exception e) {
+                        continue;
                     }
                 }
             }
         }, "ControllerI/O Thread");
         controllerIOThread.start();
-        logger.info("Controller is now listening on port " + openFlowPort);
+        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();
     }
 }