HADOOP-15764. [JDK10] Migrate from sun.net.dns.ResolverConfiguration to the replacement. Contributed by Akira Ajisaka.

This commit is contained in:
Ewan Higgs 2018-09-20 15:13:55 +02:00
parent 3da94a36e2
commit 429a07e08c
4 changed files with 33 additions and 19 deletions

View File

@ -318,6 +318,10 @@
<groupId>commons-net</groupId> <groupId>commons-net</groupId>
<artifactId>commons-net</artifactId> <artifactId>commons-net</artifactId>
</exclusion> </exclusion>
<exclusion>
<groupId>dnsjava</groupId>
<artifactId>dnsjava</artifactId>
</exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<!-- Add optional runtime dependency on the in-development timeline server module <!-- Add optional runtime dependency on the in-development timeline server module
@ -773,19 +777,6 @@
<exclude>ehcache-core.xsd</exclude> <exclude>ehcache-core.xsd</exclude>
</excludes> </excludes>
</filter> </filter>
<!-- remove utility classes which are not required from
dnsjava -->
<filter>
<artifact>dnsjava:dnsjava</artifact>
<excludes>
<excldue>dig*</excldue>
<exclude>jnamed*</exclude>
<exlcude>lookup*</exlcude>
<exclude>update*</exclude>
</excludes>
</filter>
</filters> </filters>
<!-- relocate classes from mssql-jdbc --> <!-- relocate classes from mssql-jdbc -->

View File

@ -212,6 +212,17 @@
<exclude>ccache.txt</exclude> <exclude>ccache.txt</exclude>
</excludes> </excludes>
</filter> </filter>
<!-- remove utility classes which are not required from
dnsjava -->
<filter>
<artifact>dnsjava:dnsjava</artifact>
<excludes>
<exclude>dig*</exclude>
<exclude>jnamed*</exclude>
<exclude>lookup*</exclude>
<exclude>update*</exclude>
</excludes>
</filter>
</filters> </filters>
<relocations> <relocations>
<relocation> <relocation>

View File

@ -324,6 +324,11 @@
<artifactId>mockwebserver</artifactId> <artifactId>mockwebserver</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>dnsjava</groupId>
<artifactId>dnsjava</artifactId>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -27,6 +27,7 @@
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction; import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -52,8 +53,9 @@
import org.apache.hadoop.util.ZKUtil; import org.apache.hadoop.util.ZKUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
//this will need to be replaced someday when there is a suitable replacement import org.xbill.DNS.Name;
import sun.net.dns.ResolverConfiguration; import org.xbill.DNS.ResolverConfig;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.net.InetAddresses; import com.google.common.net.InetAddresses;
@ -584,9 +586,14 @@ public InetAddress getByName(String host) throws UnknownHostException {
* hadoop.security.token.service.use_ip=false * hadoop.security.token.service.use_ip=false
*/ */
protected static class QualifiedHostResolver implements HostResolver { protected static class QualifiedHostResolver implements HostResolver {
@SuppressWarnings("unchecked") private List<String> searchDomains;
private List<String> searchDomains = {
ResolverConfiguration.open().searchlist(); 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 * Create an InetAddress with a fully qualified hostname of the given