Fix a regression where writing a ByteBuf are discarded

This commit is contained in:
Trustin Lee 2013-02-08 00:41:35 +09:00
parent 30e80f8c5c
commit b8c0751023

View File

@ -1457,38 +1457,34 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
validateFuture(promise); validateFuture(promise);
DefaultChannelHandlerContext ctx = prev; DefaultChannelHandlerContext ctx = prev;
final DefaultChannelHandlerContext initialCtx = ctx;
EventExecutor executor; EventExecutor executor;
boolean msgBuf = false; final boolean msgBuf;
for (;;) {
if (ctx.hasOutboundMessageBuffer()) {
msgBuf = true;
executor = ctx.executor();
break;
}
if (message instanceof ByteBuf && ctx.hasOutboundByteBuffer()) { if (message instanceof ByteBuf) {
executor = ctx.executor(); for (;;) {
break; if (ctx.hasOutboundByteBuffer()) {
} msgBuf = false;
executor = ctx.executor();
ctx = ctx.prev; break;
if (ctx == null) {
if (initialCtx.next != null) {
throw new NoSuchBufferException(String.format(
"the handler '%s' could not find a %s which accepts a %s, and " +
"the transport does not accept it as-is.",
initialCtx.next.name(),
ChannelOutboundHandler.class.getSimpleName(),
message.getClass().getSimpleName()));
} else {
throw new NoSuchBufferException(String.format(
"the pipeline does not contain a %s which accepts a %s, and " +
"the transport does not accept it as-is.",
ChannelOutboundHandler.class.getSimpleName(),
message.getClass().getSimpleName()));
} }
if (ctx.hasOutboundMessageBuffer()) {
msgBuf = true;
executor = ctx.executor();
break;
}
ctx = ctx.prev;
}
} else {
msgBuf = true;
for (;;) {
if (ctx.hasOutboundMessageBuffer()) {
executor = ctx.executor();
break;
}
ctx = ctx.prev;
} }
} }
@ -1497,12 +1493,11 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
return promise; return promise;
} }
final boolean msgBuf0 = msgBuf;
final DefaultChannelHandlerContext ctx0 = ctx; final DefaultChannelHandlerContext ctx0 = ctx;
executor.execute(new Runnable() { executor.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
ctx0.write0(message, promise, msgBuf0); ctx0.write0(message, promise, msgBuf);
} }
}); });