NET-650 Delegate host resolution to Socket.connect() #138
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request presents a solution of NET-650, delegating remote host resolution to
java.net.Socket.connect()
instead of performing host resolution earlier inorg.apache.commons.net.SocketClient.connect()
methods.For
SocketClient.connect()
methods that accept aString
value for thehostname
argument, the existing implementation callsInetAddress.getByName(hostname)
, performing host resolution prior to callingSocket.connect()
. This works for use cases where the remote host DNS address is resolvable, but does not work for scenarios where the remote host must be resolved through a proxy server.The
new InetSocketAddress(String hostname, int port)
constructor attempts name resolution, but catches theUnknownHostException
and allows the hostname to remain unresolved. This behavior allows custom JavaSocketFactory
implementations to pass the unresolved hostname to a remote proxy server, where name resolution may succeed, allowing the connection to proceed.Changing the
SocketClient.connect()
methods to construct anInetSocketAddress
should support existing standard behavior while also supporting additional use cases like proxy-based name resolution.The pull request includes a new
_remoteAddress_
member inSocketClient
, which supports new unit test methods that check the status ofInetSocketAddress.isUnresolved()
after expecting particular exceptions.