Fixed NPE in LocalChannel.closeNow()
This commit is contained in:
parent
f513e0d6ae
commit
f7cc2c971d
@ -109,7 +109,7 @@ class LocalChannel extends AbstractChannel {
|
|||||||
fireChannelClosed(this);
|
fireChannelClosed(this);
|
||||||
|
|
||||||
// Close the peer.
|
// Close the peer.
|
||||||
if (!pairedChannel.setClosed()) {
|
if (pairedChannel == null || !pairedChannel.setClosed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,26 +130,9 @@ class LocalChannel extends AbstractChannel {
|
|||||||
|
|
||||||
void flushWriteBuffer() {
|
void flushWriteBuffer() {
|
||||||
LocalChannel pairedChannel = this.pairedChannel;
|
LocalChannel pairedChannel = this.pairedChannel;
|
||||||
if (pairedChannel == null || !pairedChannel.isConnected()) {
|
if (isConnected()){
|
||||||
// Channel is closed or not connected yet - notify as failures.
|
// Channel is open and connected and channelConnected event has
|
||||||
Exception cause;
|
// been fired.
|
||||||
if (isOpen()) {
|
|
||||||
cause = new NotYetConnectedException();
|
|
||||||
} else {
|
|
||||||
cause = new ClosedChannelException();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
MessageEvent e = writeBuffer.poll();
|
|
||||||
if(e == null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
e.getFuture().setFailure(cause);
|
|
||||||
fireExceptionCaught(this, cause);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Channel is open and connected - trigger events.
|
|
||||||
if (!delivering.get()) {
|
if (!delivering.get()) {
|
||||||
delivering.set(true);
|
delivering.set(true);
|
||||||
try {
|
try {
|
||||||
@ -167,6 +150,34 @@ class LocalChannel extends AbstractChannel {
|
|||||||
delivering.set(false);
|
delivering.set(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pairedChannel != null) {
|
||||||
|
// Channel is open and connected but channelConnected event has
|
||||||
|
// not been fired yet.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pairedChannel == null || !isOpen()) {
|
||||||
|
// Channel is closed or not connected yet - notify as failures.
|
||||||
|
Exception cause;
|
||||||
|
if (isOpen()) {
|
||||||
|
cause = new NotYetConnectedException();
|
||||||
|
} else {
|
||||||
|
cause = new ClosedChannelException();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
MessageEvent e = writeBuffer.poll();
|
||||||
|
if(e == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
e.getFuture().setFailure(cause);
|
||||||
|
fireExceptionCaught(this, cause);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user