From 2950c5405ba95ddd53f02cd095184eeb73923bf9 Mon Sep 17 00:00:00 2001 From: Ashutosh Gupta Date: Tue, 20 Sep 2022 18:39:59 +0100 Subject: [PATCH] HADOOP-16674. Fix when TestDNS.testRDNS can fail with ServiceUnavailableException (#4802). Contributed by Ashutosh Gupta. Signed-off-by: Ayush Saxena --- .../src/test/java/org/apache/hadoop/net/TestDNS.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestDNS.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestDNS.java index 2504a6401a..d33545ab6f 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestDNS.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestDNS.java @@ -25,10 +25,12 @@ import javax.naming.CommunicationException; import javax.naming.NameNotFoundException; +import javax.naming.ServiceUnavailableException; import org.apache.hadoop.util.Time; import org.assertj.core.api.Assertions; +import org.junit.Assume; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -167,7 +169,7 @@ public void testRDNS() throws Exception { try { String s = DNS.reverseDns(localhost, null); LOG.info("Local reverse DNS hostname is " + s); - } catch (NameNotFoundException | CommunicationException e) { + } catch (NameNotFoundException | CommunicationException | ServiceUnavailableException e) { if (!localhost.isLinkLocalAddress() || localhost.isLoopbackAddress()) { //these addresses probably won't work with rDNS anyway, unless someone //has unusual entries in their DNS server mapping 1.0.0.127 to localhost @@ -176,6 +178,7 @@ public void testRDNS() throws Exception { + " Loopback=" + localhost.isLoopbackAddress() + " Linklocal=" + localhost.isLinkLocalAddress()); } + Assume.assumeNoException(e); } }