From e4e5c36577707df5b1dcd909889c326ac3d611e3 Mon Sep 17 00:00:00 2001 From: Anton Keks Date: Mon, 15 Feb 2021 20:46:46 +0200 Subject: [PATCH] handle "Invalid argument" ConnectionException as host is down (e.g. invalid IPv6 address) --- src/net/azib/ipscan/core/net/TCPPinger.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/net/azib/ipscan/core/net/TCPPinger.java b/src/net/azib/ipscan/core/net/TCPPinger.java index 0817c056..7cce37a6 100644 --- a/src/net/azib/ipscan/core/net/TCPPinger.java +++ b/src/net/azib/ipscan/core/net/TCPPinger.java @@ -73,16 +73,15 @@ public class TCPPinger implements Pinger { // we've got an RST packet from the host - it is alive success(result, startTime); } - else - // this should result in NoRouteToHostException or ConnectException, but not all Java implementation respect that - if (e instanceof NoRouteToHostException || msg.contains(/*No*/"route to host") || msg.contains(/*Host is*/"down") || msg.contains(/*Network*/"unreachable") || msg.contains(/*Socket*/"closed")) { - // host is down - break; - } - else { - // something unknown - LOG.log(INFO, subject.toString(), e); - } + // this should result in NoRouteToHostException or ConnectException, but not all Java implementation respect that + else if (e instanceof NoRouteToHostException || msg.contains(/*No*/"route to host") || msg.contains(/*Host is*/"down") || msg.contains(/*Network*/"unreachable") || msg.contains(/*Socket*/"closed") || msg.contains("Invalid argument")) { + // host is down + break; + } + else { + // something unknown + LOG.log(INFO, subject.toString(), e); + } } finally { closeQuietly(socket);