Browse Source

HADOOP-17840: Backport HADOOP-17837 to branch-3.2 (#3275)

    Reviewed-by: Brahma Reddy Battula <brahma@apache.org>
Bryan Beaudreault 3 years ago
parent
commit
dab829063d

+ 1 - 1
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java

@@ -537,7 +537,7 @@ public class NetUtils {
     } catch (SocketTimeoutException ste) {
     } catch (SocketTimeoutException ste) {
       throw new ConnectTimeoutException(ste.getMessage());
       throw new ConnectTimeoutException(ste.getMessage());
     }  catch (UnresolvedAddressException uae) {
     }  catch (UnresolvedAddressException uae) {
-      throw new UnknownHostException(uae.getMessage());
+      throw new UnknownHostException(endpoint.toString());
     }
     }
 
 
     // There is a very rare case allowed by the TCP specification, such that
     // There is a very rare case allowed by the TCP specification, such that

+ 2 - 0
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java

@@ -43,6 +43,7 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.security.KerberosAuthException;
 import org.apache.hadoop.security.KerberosAuthException;
 import org.apache.hadoop.security.NetUtilsTestResolver;
 import org.apache.hadoop.security.NetUtilsTestResolver;
+import org.apache.hadoop.test.GenericTestUtils;
 import org.junit.Assume;
 import org.junit.Assume;
 import org.junit.Before;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.BeforeClass;
@@ -111,6 +112,7 @@ public class TestNetUtils {
       fail("Should not have connected");
       fail("Should not have connected");
     } catch (UnknownHostException uhe) {
     } catch (UnknownHostException uhe) {
       LOG.info("Got exception: ", uhe);
       LOG.info("Got exception: ", uhe);
+      GenericTestUtils.assertExceptionContains("invalid-test-host:0", uhe);
     }
     }
   }
   }