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 67e7673750)
This commit is contained in:
Varun Saxena 2017-10-25 03:06:12 +05:30
parent 107afed848
commit 5be228e43b
1 changed files with 21 additions and 12 deletions

View File

@ -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: "