From 5e54d92e6ec866dc49a750110863a3fa8b2bcf7c Mon Sep 17 00:00:00 2001 From: Bryan Beaudreault Date: Fri, 6 Aug 2021 05:00:20 -0400 Subject: [PATCH] HADOOP-17837: Add unresolved endpoint value to UnknownHostException (#3272) --- .../src/main/java/org/apache/hadoop/net/NetUtils.java | 2 +- .../src/test/java/org/apache/hadoop/net/TestNetUtils.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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 0f4dd9d897..efddc0e5c9 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 @@ -589,7 +589,7 @@ public static void connect(Socket socket, } catch (SocketTimeoutException ste) { throw new ConnectTimeoutException(ste.getMessage()); } 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 diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java index cfffd85186..c21932c2bd 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java @@ -111,6 +111,7 @@ public void testInvalidAddress() throws Throwable { fail("Should not have connected"); } catch (UnknownHostException uhe) { LOG.info("Got exception: ", uhe); + assertEquals("invalid-test-host:0", uhe.getMessage()); } }