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 be6cdb4a11
commit 5c75915f4c

View File

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