--- old/src/java.base/share/classes/java/net/DatagramSocket.java 2019-12-17 14:39:09.000000000 +0000 +++ new/src/java.base/share/classes/java/net/DatagramSocket.java 2019-12-17 14:39:09.000000000 +0000 @@ -26,6 +26,7 @@ package java.net; import java.io.IOException; +import java.io.UncheckedIOException; import java.nio.channels.DatagramChannel; import java.security.AccessController; import java.security.PrivilegedExceptionAction; @@ -498,13 +499,17 @@ * if a security manager has been installed and it does * not permit access to the given remote address * + * @throws UncheckedIOException + * May be thrown by an implementation if connect fails, + * for example, if the destination address is non-routable + * * @see #disconnect */ public void connect(InetAddress address, int port) { try { connectInternal(address, port); } catch (SocketException se) { - throw new Error("connect failed", se); + throw new UncheckedIOException("connect failed", se); } } @@ -545,6 +550,14 @@ * Disconnects the socket. If the socket is closed or not connected, * then this method has no effect. * + * @apiNote If this method throws an UncheckedIOException, the socket + * may be left in an unspecified state. It is strongly recommended that + * the socket be closed when disconnect fails. + * + * @throws UncheckedIOException + * May be thrown by an implementation if it fails to dissolve the + * association and restore the socket to a consistent state. + * * @see #connect */ public void disconnect() {