From 7659b626828d1579fdcb8505937298c86bdfd237 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) (cherry picked from commit 5e54d92e6ec866dc49a750110863a3fa8b2bcf7c) --- .../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 6c7e443463..f1e209fe1f 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 @@ -588,7 +588,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()); } }