Fail unflushed writes with ClosedChannelException
... instead of cryptic exception message.
This commit is contained in:
parent
5f235eafc3
commit
88cbdb50d2
@ -511,7 +511,7 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
|||||||
outboundBuffer.fail(CLOSED_CHANNEL_EXCEPTION);
|
outboundBuffer.fail(CLOSED_CHANNEL_EXCEPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
outboundBuffer.clearUnflushed();
|
outboundBuffer.clearUnflushed(CLOSED_CHANNEL_EXCEPTION);
|
||||||
|
|
||||||
if (wasActive && !isActive()) {
|
if (wasActive && !isActive()) {
|
||||||
invokeLater(new Runnable() {
|
invokeLater(new Runnable() {
|
||||||
|
@ -211,7 +211,7 @@ final class ChannelOutboundBuffer {
|
|||||||
return head == tail;
|
return head == tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearUnflushed() {
|
void clearUnflushed(Throwable cause) {
|
||||||
MessageList unflushed = unflushedMessageList;
|
MessageList unflushed = unflushedMessageList;
|
||||||
if (unflushed == null) {
|
if (unflushed == null) {
|
||||||
return;
|
return;
|
||||||
@ -221,17 +221,13 @@ final class ChannelOutboundBuffer {
|
|||||||
Object[] messages = unflushed.messages();
|
Object[] messages = unflushed.messages();
|
||||||
ChannelPromise[] promises = unflushed.promises();
|
ChannelPromise[] promises = unflushed.promises();
|
||||||
final int size = unflushed.size();
|
final int size = unflushed.size();
|
||||||
Throwable flushAborted = null;
|
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
ReferenceCountUtil.release(messages[i]);
|
ReferenceCountUtil.release(messages[i]);
|
||||||
ChannelPromise p = promises[i];
|
ChannelPromise p = promises[i];
|
||||||
if (!(p instanceof VoidChannelPromise)) {
|
if (!(p instanceof VoidChannelPromise)) {
|
||||||
if (flushAborted == null) {
|
if (!p.tryFailure(cause)) {
|
||||||
flushAborted = new ChannelException("write() aborted without flush()");
|
logger.warn("Promise done already: {} - new exception is:", p, cause);
|
||||||
}
|
|
||||||
if (!p.tryFailure(flushAborted)) {
|
|
||||||
logger.warn("Promise done already: {} - new exception is:", p, flushAborted);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user