Skip to content

Remove IP literal check for InetAddressResolver #1120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 31, 2023
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