HADOOP-9657. NetUtils.wrapException to have special handling for 0.0.0.0 addresses and :0 ports. Contributed by Varun Saxena.

This commit is contained in:
Varun Saxena 2017-10-25 03:06:12 +05:30
parent 03af442e76
commit 67e7673750

View File

@ -742,6 +742,14 @@ public static IOException wrapException(final String destHost,
+ ";" + ";"
+ see("BindException")); + see("BindException"));
} else if (exception instanceof ConnectException) { } else if (exception instanceof ConnectException) {
// 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 // connection refused; include the host:port in the error
return wrapWithMessage(exception, return wrapWithMessage(exception,
"Call From " "Call From "
@ -754,6 +762,7 @@ public static IOException wrapException(final String destHost,
+ exception + exception
+ ";" + ";"
+ see("ConnectionRefused")); + see("ConnectionRefused"));
}
} else if (exception instanceof UnknownHostException) { } else if (exception instanceof UnknownHostException) {
return wrapWithMessage(exception, return wrapWithMessage(exception,
"Invalid host name: " "Invalid host name: "