From 429a07e08c8c919b1679c0a80df73d147d95e8a6 Mon Sep 17 00:00:00 2001 From: Ewan Higgs Date: Thu, 20 Sep 2018 15:13:55 +0200 Subject: [PATCH] HADOOP-15764. [JDK10] Migrate from sun.net.dns.ResolverConfiguration to the replacement. Contributed by Akira Ajisaka. --- .../hadoop-client-minicluster/pom.xml | 17 ++++------------- .../hadoop-client-runtime/pom.xml | 11 +++++++++++ hadoop-common-project/hadoop-common/pom.xml | 5 +++++ .../apache/hadoop/security/SecurityUtil.java | 19 +++++++++++++------ 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/hadoop-client-modules/hadoop-client-minicluster/pom.xml b/hadoop-client-modules/hadoop-client-minicluster/pom.xml index ea8d6800d0..70fca8a89c 100644 --- a/hadoop-client-modules/hadoop-client-minicluster/pom.xml +++ b/hadoop-client-modules/hadoop-client-minicluster/pom.xml @@ -318,6 +318,10 @@ commons-net commons-net + + dnsjava + dnsjava + - - dnsjava:dnsjava - - dig* - jnamed* - lookup* - update* - - - diff --git a/hadoop-client-modules/hadoop-client-runtime/pom.xml b/hadoop-client-modules/hadoop-client-runtime/pom.xml index 532fae960b..bfa6c15244 100644 --- a/hadoop-client-modules/hadoop-client-runtime/pom.xml +++ b/hadoop-client-modules/hadoop-client-runtime/pom.xml @@ -212,6 +212,17 @@ ccache.txt + + + dnsjava:dnsjava + + dig* + jnamed* + lookup* + update* + + diff --git a/hadoop-common-project/hadoop-common/pom.xml b/hadoop-common-project/hadoop-common/pom.xml index 695dcdee58..1e6da927e7 100644 --- a/hadoop-common-project/hadoop-common/pom.xml +++ b/hadoop-common-project/hadoop-common/pom.xml @@ -324,6 +324,11 @@ mockwebserver test + + dnsjava + dnsjava + compile + diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java index 0de334ab8a..9fea535ec0 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java @@ -27,6 +27,7 @@ import java.net.UnknownHostException; import java.security.PrivilegedAction; import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -52,8 +53,9 @@ import org.apache.hadoop.util.ZKUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -//this will need to be replaced someday when there is a suitable replacement -import sun.net.dns.ResolverConfiguration; +import org.xbill.DNS.Name; +import org.xbill.DNS.ResolverConfig; + import com.google.common.annotations.VisibleForTesting; import com.google.common.net.InetAddresses; @@ -584,10 +586,15 @@ public InetAddress getByName(String host) throws UnknownHostException { * hadoop.security.token.service.use_ip=false */ protected static class QualifiedHostResolver implements HostResolver { - @SuppressWarnings("unchecked") - private List searchDomains = - ResolverConfiguration.open().searchlist(); - + private List searchDomains; + { + ResolverConfig resolverConfig = ResolverConfig.getCurrentConfig(); + searchDomains = new ArrayList<>(); + for (Name name : resolverConfig.searchPath()) { + searchDomains.add(name.toString()); + } + } + /** * Create an InetAddress with a fully qualified hostname of the given * hostname. InetAddress does not qualify an incomplete hostname that