Revert "WIP: Bump upstreams"
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / core / UdpHandler.java
index 32f164be9c8b5342c43eacdef9f5f58e74ab50ce..3a373c96b0e817882d9925e7acf4935e92d99725 100644 (file)
@@ -38,7 +38,7 @@ public final class UdpHandler implements ServerFacade {
     private EventLoopGroup group;
     private final InetAddress startupAddress;
     private final Runnable readyRunnable;
-    private final SettableFuture<Boolean> isOnlineFuture;
+    private final SettableFuture<Boolean> isOnlineFuture = SettableFuture.create();
     private UdpChannelInitializer channelInitializer;
     private ThreadConfiguration threadConfig;
     private Class<? extends DatagramChannel> datagramChannelClass;
@@ -60,11 +60,11 @@ public final class UdpHandler implements ServerFacade {
     public UdpHandler(final InetAddress address, final int port, Runnable readyRunnable) {
         this.port = port;
         this.startupAddress = address;
-        isOnlineFuture = SettableFuture.create();
         this.readyRunnable = readyRunnable;
     }
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public void run() {
         final ChannelFuture f;
         try {
@@ -80,6 +80,10 @@ public final class UdpHandler implements ServerFacade {
         } catch (InterruptedException e) {
             LOG.error("Interrupted while binding port {}", port, e);
             return;
+        } catch (Throwable throwable) {
+            // sync() re-throws exceptions declared as Throwable, so the compiler doesn't see them
+            LOG.error("Error while binding address {} and port {}", startupAddress, port, throwable);
+            throw throwable;
         }
 
         try {
@@ -90,9 +94,10 @@ public final class UdpHandler implements ServerFacade {
             this.port = isa.getPort();
 
             LOG.debug("Address from udpHandler: {}", address);
-            isOnlineFuture.set(true);
             LOG.info("Switch listener started and ready to accept incoming udp connections on port: {}", port);
             readyRunnable.run();
+            isOnlineFuture.set(true);
+
             // This waits until this channel is closed, and rethrows the cause of the failure if this future failed.
             f.channel().closeFuture().sync();
         } catch (InterruptedException e) {
@@ -138,7 +143,6 @@ public final class UdpHandler implements ServerFacade {
      * @param threadConfiguration number of threads to be created, if not specified in threadConfig
      */
     public void initiateEventLoopGroups(ThreadConfiguration threadConfiguration, boolean isEpollEnabled) {
-
         if (isEpollEnabled) {
             initiateEpollEventLoopGroups(threadConfiguration);
         } else {