HADOOP-9657. NetUtils.wrapException to have special handling for 0.0.0.0 addresses and :0 ports. Contributed by Varun Saxena.
(cherry picked from commit 67e7673750e731f5ecfa84e82b84b7fc7ee0b233) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/5be228e4 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/5be228e4 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/5be228e4 Branch: refs/heads/resource-types Commit: 5be228e43b0f12f8c319b93312be8106e2900c27 Parents: 107afed Author: Varun Saxena <varunsax...@apache.org> Authored: Wed Oct 25 03:06:12 2017 +0530 Committer: Varun Saxena <varunsax...@apache.org> Committed: Wed Oct 25 03:22:18 2017 +0530 ---------------------------------------------------------------------- .../java/org/apache/hadoop/net/NetUtils.java | 33 +++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/5be228e4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java index 8577336..4697320 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java @@ -742,18 +742,27 @@ public class NetUtils { + ";" + see("BindException")); } else if (exception instanceof ConnectException) { - // connection refused; include the host:port in the error - return wrapWithMessage(exception, - "Call From " - + localHost - + " to " - + destHost - + ":" - + destPort - + " failed on connection exception: " - + exception - + ";" - + see("ConnectionRefused")); + // Check if client was trying to connect to an unspecified IPv4 address + // (0.0.0.0) or IPv6 address(0:0:0:0:0:0:0:0 or ::) + if ((destHost != null && (destHost.equals("0.0.0.0") || + destHost.equals("0:0:0:0:0:0:0:0") || destHost.equals("::"))) + || destPort == 0) { + return wrapWithMessage(exception, "Your endpoint configuration" + + " is wrong;" + see("UnsetHostnameOrPort")); + } else { + // connection refused; include the host:port in the error + return wrapWithMessage(exception, + "Call From " + + localHost + + " to " + + destHost + + ":" + + destPort + + " failed on connection exception: " + + exception + + ";" + + see("ConnectionRefused")); + } } else if (exception instanceof UnknownHostException) { return wrapWithMessage(exception, "Invalid host name: " --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org