HADOOP-15756. [JDK10] Migrate from sun.net.util.IPAddressUtil to the replacement. Contributed by Akira Ajisaka.
This commit is contained in:
parent
646874c326
commit
3da94a36e2
@ -54,9 +54,9 @@
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
//this will need to be replaced someday when there is a suitable replacement
|
//this will need to be replaced someday when there is a suitable replacement
|
||||||
import sun.net.dns.ResolverConfiguration;
|
import sun.net.dns.ResolverConfiguration;
|
||||||
import sun.net.util.IPAddressUtil;
|
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
import com.google.common.net.InetAddresses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Security Utils.
|
* Security Utils.
|
||||||
@ -604,14 +604,11 @@ protected static class QualifiedHostResolver implements HostResolver {
|
|||||||
public InetAddress getByName(String host) throws UnknownHostException {
|
public InetAddress getByName(String host) throws UnknownHostException {
|
||||||
InetAddress addr = null;
|
InetAddress addr = null;
|
||||||
|
|
||||||
if (IPAddressUtil.isIPv4LiteralAddress(host)) {
|
if (InetAddresses.isInetAddress(host)) {
|
||||||
// use ipv4 address as-is
|
// valid ip address. use it as-is
|
||||||
byte[] ip = IPAddressUtil.textToNumericFormatV4(host);
|
addr = InetAddresses.forString(host);
|
||||||
addr = InetAddress.getByAddress(host, ip);
|
// set hostname
|
||||||
} else if (IPAddressUtil.isIPv6LiteralAddress(host)) {
|
addr = InetAddress.getByAddress(host, addr.getAddress());
|
||||||
// use ipv6 address as-is
|
|
||||||
byte[] ip = IPAddressUtil.textToNumericFormatV6(host);
|
|
||||||
addr = InetAddress.getByAddress(host, ip);
|
|
||||||
} else if (host.endsWith(".")) {
|
} else if (host.endsWith(".")) {
|
||||||
// a rooted host ends with a dot, ex. "host."
|
// a rooted host ends with a dot, ex. "host."
|
||||||
// rooted hosts never use the search path, so only try an exact lookup
|
// rooted hosts never use the search path, so only try an exact lookup
|
||||||
|
Loading…
Reference in New Issue
Block a user