Skip to content

Commit

Permalink
8313356: Improve address selection in sun.net.NetworkClient
Browse files Browse the repository at this point in the history
  • Loading branch information
cushon committed Jul 28, 2023
1 parent 402cb6a commit b1f1993
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/java.base/share/classes/sun/net/NetworkClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,23 @@ public void openServer(String server, int port)
* appropriate options pre-established
*/
protected Socket doConnect (String server, int port)
throws IOException, UnknownHostException {
IOException exception = null;
for (InetAddress address : InetAddress.getAllByName(server)) {
try {
return doConnect(address, port);
} catch (IOException e) {
if (exception == null) {
exception = e;
} else {
exception.addSuppressed(e);
}
}
}
throw exception;
}

private Socket doConnect (InetAddress server, int port)
throws IOException, UnknownHostException {
Socket s;
if (proxy != null) {
Expand Down

0 comments on commit b1f1993

Please sign in to comment.