From 5eab85cc2b9726f4d0c63547a05b044874052991 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 29 Jan 2018 15:47:08 +0100 Subject: [PATCH] Report IOExceptions in AbstractNioSender.isConnected() with a meaningful message #126 --- .../logging/gelf/intern/sender/AbstractNioSender.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/biz/paluch/logging/gelf/intern/sender/AbstractNioSender.java b/src/main/java/biz/paluch/logging/gelf/intern/sender/AbstractNioSender.java index f3fbac0f2..d5a945ad5 100644 --- a/src/main/java/biz/paluch/logging/gelf/intern/sender/AbstractNioSender.java +++ b/src/main/java/biz/paluch/logging/gelf/intern/sender/AbstractNioSender.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.net.InetAddress; +import java.net.PortUnreachableException; import java.net.UnknownHostException; import java.nio.ByteBuffer; import java.nio.channels.ByteChannel; @@ -74,8 +75,11 @@ protected boolean isConnected() throws IOException { try { return channel.read(byteBuffer) >= 0; + } catch (PortUnreachableException e) { + errorReporter.reportError("Port " + getHost() + ":" + getPort() + " not reachable", e); } catch (IOException e) { - errorReporter.reportError(e.getMessage(), e); + errorReporter.reportError("Cannot verify whether channel to " + getHost() + ":" + getPort() + " is connected: " + + e.getMessage(), e); } }