-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: Connection Management
-
None
-
Fully Compatible
-
Not Needed
-
As part of JAVA-4911, the InetAddressResolver interface was added, and, if configured, the driver is supposed to use it to resolve host names to IP addresses. However, it's not supposed to use it to if the address is an IP literal. To detect this, the driver makes the following check:
// 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) == ':'); }
This check is incorrect, as it will treat any host name starting with the characters 'a' through 'f' as IP literals.
Looking at the JDK source more closely, it's not such a simple check to see if a string is an IP literal, as it involves parsing the whole string, and there is also a system property, "jdk.net.allowAmbiguousIPAddressLiterals", which figures into the determination.
But the check in the driver is wrong, so we either need to:
- Fully and properly implement the check for IP literals
- Delegate that determination to the configured InetAddressResolver.
It was decided to implement the second option