Log the address and port on bind errors
[ovsdb.git] / library / impl / src / main / java / org / opendaylight / ovsdb / lib / impl / OvsdbConnectionService.java
index ed502369c88fba86726da5d53b2b7c4eacfb85a9..da3f7c30b1fcc89b5db84a1bf4148de6c792ea9c 100644 (file)
@@ -140,6 +140,7 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
     }
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public OvsdbClient connectWithSsl(final InetAddress address, final int port,
                                final ICertificateManager certificateManagerSrv) {
         try {
@@ -175,6 +176,10 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
             return getChannelClient(channel, ConnectionType.ACTIVE, SocketConnectionType.SSL);
         } catch (InterruptedException e) {
             LOG.warn("Failed to connect {}:{}", address, port, e);
+        } catch (Throwable throwable) {
+            // sync() re-throws exceptions declared as Throwable, so the compiler doesn't see them
+            LOG.error("Error while binding to address {}, port {}", address, port, throwable);
+            throw throwable;
         }
         return null;
     }
@@ -309,6 +314,7 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
      * OVSDB Passive listening thread that uses Netty ServerBootstrap to open
      * passive connection with Ssl and handle channel callbacks.
      */
+    @SuppressWarnings("checkstyle:IllegalCatch")
     private void ovsdbManagerWithSsl(String ip, int port, final ICertificateManager certificateManagerSrv,
                                             final String[] protocols, final String[] cipherSuites) {
         EventLoopGroup bossGroup = new NioEventLoopGroup();
@@ -367,6 +373,10 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
             serverListenChannel.closeFuture().sync();
         } catch (InterruptedException e) {
             LOG.error("Thread interrupted", e);
+        } catch (Throwable throwable) {
+            // sync() re-throws exceptions declared as Throwable, so the compiler doesn't see them
+            LOG.error("Error while binding to address {}, port {}", ip, port, throwable);
+            throw throwable;
         } finally {
             // Shut down all event loops to terminate all threads.
             bossGroup.shutdownGracefully();