From 2768646631c03137a50679c8e5eab63cd5e1672d Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Wed, 28 Nov 2018 11:01:47 +0100 Subject: [PATCH] Log the address and port on bind errors This ensures the address and port are available in the logs when we fail to bind. Change-Id: Iae6a6fd4d6f516d5dbd562a335d081181cff3b17 JIRA: OVSDB-473 Signed-off-by: Stephen Kitt --- .../ovsdb/lib/impl/OvsdbConnectionService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java index ed502369c..da3f7c30b 100644 --- a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java +++ b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java @@ -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(); -- 2.36.6