# HG changeset patch # User bpb # Date 1573751203 28800 # Node ID de56632f796d4b15044502217b9be6d593e35aae # Parent 3e4d8b5856f3ae074be2fdfce96094feb7968b4d 8146298: (dc spec) connect and disconnect methods should specify that they may block Reviewed-by: alanb, chegar, dfuchs, darcy diff -r 3e4d8b5856f3 -r de56632f796d src/java.base/share/classes/java/nio/channels/DatagramChannel.java --- a/src/java.base/share/classes/java/nio/channels/DatagramChannel.java Thu Nov 14 10:54:32 2019 -0500 +++ b/src/java.base/share/classes/java/nio/channels/DatagramChannel.java Thu Nov 14 09:06:43 2019 -0800 @@ -255,8 +255,11 @@ *

The channel's socket is configured so that it only receives * datagrams from, and sends datagrams to, the given remote peer * address. Once connected, datagrams may not be received from or sent to - * any other address. A datagram socket remains connected until it is - * explicitly disconnected or until it is closed. + * any other address. Datagrams in the channel's {@linkplain + * java.net.StandardSocketOptions#SO_RCVBUF socket receive buffer}, which + * have not been {@linkplain #receive(ByteBuffer) received} before invoking + * this method, may be discarded. The channel's socket remains connected + * until it is explicitly disconnected or until it is closed. * *

This method performs exactly the same security checks as the {@link * java.net.DatagramSocket#connect connect} method of the {@link @@ -270,12 +273,13 @@ * should be taken to ensure that a connected datagram channel is not shared * with untrusted code. * - *

This method may be invoked at any time. It will not have any effect - * on read or write operations that are already in progress at the moment - * that it is invoked. If this channel's socket is not bound then this method - * will first cause the socket to be bound to an address that is assigned + *

This method may be invoked at any time. If another thread has + * already initiated a read or write operation upon this channel, then an + * invocation of this method will block until any such operation is + * complete. If this channel's socket is not bound then this method will + * first cause the socket to be bound to an address that is assigned * automatically, as if invoking the {@link #bind bind} method with a - * parameter of {@code null}.

+ * parameter of {@code null}.

* * @param remote * The remote address to which this channel is to be connected @@ -323,9 +327,10 @@ * from, and sends datagrams to, any remote address so long as the security * manager, if installed, permits it. * - *

This method may be invoked at any time. It will not have any effect - * on read or write operations that are already in progress at the moment - * that it is invoked. + *

This method may be invoked at any time. If another thread has + * already initiated a read or write operation upon this channel, then an + * invocation of this method will block until any such operation is + * complete. * *

If this channel's socket is not connected, or if the channel is * closed, then invoking this method has no effect.