@@ -569,9 +569,8 @@ void setConnected() {
569569 /**
570570 * Connects this socket to the server.
571571 *
572- * <p> If the endpoint is an unresolved {@link InetSocketAddress}, or the
573- * connection cannot be established, then the socket is closed, and an
574- * {@link IOException} is thrown.
572+ * <p> If the connection cannot be established, then the socket is closed,
573+ * and an {@link IOException} is thrown.
575574 *
576575 * <p> This method is {@linkplain Thread#interrupt() interruptible} in the
577576 * following circumstances:
@@ -591,8 +590,8 @@ void setConnected() {
591590 * @param endpoint the {@code SocketAddress}
592591 * @throws IOException if an error occurs during the connection, the socket
593592 * is already connected or the socket is closed
594- * @throws UnknownHostException if the endpoint is an unresolved
595- * {@link InetSocketAddress}
593+ * @throws UnknownHostException if the connection could not be established
594+ * because the endpoint is an unresolved {@link InetSocketAddress}
596595 * @throws java.nio.channels.IllegalBlockingModeException
597596 * if this socket has an associated channel,
598597 * and the channel is in non-blocking mode
@@ -609,9 +608,8 @@ public void connect(SocketAddress endpoint) throws IOException {
609608 * A timeout of zero is interpreted as an infinite timeout. The connection
610609 * will then block until established or an error occurs.
611610 *
612- * <p> If the endpoint is an unresolved {@link InetSocketAddress}, the
613- * connection cannot be established, or the timeout expires before the
614- * connection is established, then the socket is closed, and an
611+ * <p> If the connection cannot be established, or the timeout expires
612+ * before the connection is established, then the socket is closed, and an
615613 * {@link IOException} is thrown.
616614 *
617615 * <p> This method is {@linkplain Thread#interrupt() interruptible} in the
@@ -634,8 +632,8 @@ public void connect(SocketAddress endpoint) throws IOException {
634632 * @throws IOException if an error occurs during the connection, the socket
635633 * is already connected or the socket is closed
636634 * @throws SocketTimeoutException if timeout expires before connecting
637- * @throws UnknownHostException if the endpoint is an unresolved
638- * {@link InetSocketAddress}
635+ * @throws UnknownHostException if the connection could not be established
636+ * because the endpoint is an unresolved {@link InetSocketAddress}
639637 * @throws java.nio.channels.IllegalBlockingModeException
640638 * if this socket has an associated channel,
641639 * and the channel is in non-blocking mode
@@ -660,12 +658,6 @@ public void connect(SocketAddress endpoint, int timeout) throws IOException {
660658 if (!(endpoint instanceof InetSocketAddress epoint ))
661659 throw new IllegalArgumentException ("Unsupported address type" );
662660
663- if (epoint .isUnresolved ()) {
664- var uhe = new UnknownHostException (epoint .getHostName ());
665- closeSuppressingExceptions (uhe );
666- throw uhe ;
667- }
668-
669661 InetAddress addr = epoint .getAddress ();
670662 checkAddress (addr , "connect" );
671663
0 commit comments