This ensures the address and port are available in the logs when we
fail to bind.
Change-Id: I100f68112d90573333340b4dc3e0a6f73c8ad90a
JIRA: NETCONF-585
Signed-off-by: Stephen Kitt <skitt@redhat.com>
(cherry picked from commit
1fca5bf02873a124ea0dfcf91ea44ac9bc57acd4)
client.start();
acceptor.bind(bindAddress);
} catch (IOException e) {
- LOG.error("Unable to start NETCONF CallHome Service", e);
+ LOG.error("Unable to start NETCONF CallHome Service on {}", bindAddress, e);
throw e;
}
}
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import java.net.InetSocketAddress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ProxyServer implements AutoCloseable {
+ private static final Logger LOG = LoggerFactory.getLogger(ProxyServer.class);
+
private final EventLoopGroup bossGroup = new NioEventLoopGroup();
private final EventLoopGroup workerGroup = new NioEventLoopGroup();
private final ChannelFuture channelFuture;
+ @SuppressWarnings("checkstyle:IllegalCatch")
public ProxyServer(InetSocketAddress address, final LocalAddress localAddress) {
// Configure the server.
final Bootstrap clientBootstrap = new Bootstrap();
});
// Start the server.
- channelFuture = serverBootstrap.bind(address).syncUninterruptibly();
+ try {
+ channelFuture = serverBootstrap.bind(address).syncUninterruptibly();
+ } catch (Throwable throwable) {
+ // sync() re-throws exceptions declared as Throwable, so the compiler doesn't see them
+ LOG.error("Error while binding to address {}", address, throwable);
+ throw throwable;
+ }
}
@Override
}
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void run() {
bossGroup = new NioEventLoopGroup();
workerGroup = new NioEventLoopGroup();
channel.closeFuture().sync();
} catch (final InterruptedException e) {
LOG.error("Web socket server encountered an error during startup attempt on port {}", 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;
} finally {
stop();
}
}
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void run() {
bossGroup = new NioEventLoopGroup();
workerGroup = new NioEventLoopGroup();
channel.closeFuture().sync();
} catch (final InterruptedException e) {
LOG.error("Web socket server encountered an error during startup attempt on port {}", 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 port {}", port, throwable);
+ throw throwable;
} finally {
stop();
}