Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public InetSocketAddress getSocketAddress() {

@Override
public List<InetSocketAddress> getSocketAddresses() {
if (resolver == null || isIpLiteral()) {
if (resolver == null) {
return super.getSocketAddresses();
}
try {
Expand All @@ -74,11 +74,6 @@ public List<InetSocketAddress> getSocketAddresses() {
}
}

// If this returns true, it's either an IP literal or a malformed hostname. But either way, skip lookup via resolver
private boolean isIpLiteral() {
return getHost().charAt(0) == '[' || Character.digit(getHost().charAt(0), 16) != -1 || (getHost().charAt(0) == ':');
}

@Override
public boolean equals(final Object o) {
if (this == o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public interface InetAddressResolver {
* Given the name of a host, returns a list of IP addresses of the requested
* address family associated with a provided hostname.
*
* <p>The host name can be an IP literal, as with {@link InetAddress#getAllByName(String)}</p>
*
* <p>Implementations are encouraged to implement their own caching policies, as there is
* no guarantee that the caller will implement a cache.
*
Expand Down