NioDatagramWorker should reject the write attempt on an unbound

socket, raising NotYetBoundException.
This commit is contained in:
Trustin Lee 2011-02-01 11:35:26 +09:00
parent dfe960855f
commit d8ff180610

View File

@ -24,7 +24,7 @@ import java.nio.channels.AsynchronousCloseException;
import java.nio.channels.CancelledKeyException; import java.nio.channels.CancelledKeyException;
import java.nio.channels.ClosedChannelException; import java.nio.channels.ClosedChannelException;
import java.nio.channels.DatagramChannel; import java.nio.channels.DatagramChannel;
import java.nio.channels.NotYetConnectedException; import java.nio.channels.NotYetBoundException;
import java.nio.channels.SelectionKey; import java.nio.channels.SelectionKey;
import java.nio.channels.Selector; import java.nio.channels.Selector;
import java.util.Iterator; import java.util.Iterator;
@ -442,7 +442,7 @@ class NioDatagramWorker implements Runnable {
* has a different meaning in UDP and means that the channels socket is * has a different meaning in UDP and means that the channels socket is
* configured to only send and receive from a given remote peer. * configured to only send and receive from a given remote peer.
*/ */
if (!channel.isOpen()) { if (!channel.isBound()) {
cleanUpWriteBuffer(channel); cleanUpWriteBuffer(channel);
return; return;
} }
@ -694,7 +694,7 @@ class NioDatagramWorker implements Runnable {
// Create the exception only once to avoid the excessive overhead // Create the exception only once to avoid the excessive overhead
// caused by fillStackTrace. // caused by fillStackTrace.
if (channel.isOpen()) { if (channel.isOpen()) {
cause = new NotYetConnectedException(); cause = new NotYetBoundException();
} else { } else {
cause = new ClosedChannelException(); cause = new ClosedChannelException();
} }
@ -714,7 +714,7 @@ class NioDatagramWorker implements Runnable {
// caused by fillStackTrace. // caused by fillStackTrace.
if (cause == null) { if (cause == null) {
if (channel.isOpen()) { if (channel.isOpen()) {
cause = new NotYetConnectedException(); cause = new NotYetBoundException();
} else { } else {
cause = new ClosedChannelException(); cause = new ClosedChannelException();
} }