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;
if (message instanceof ByteBuf) {
for (;;) { for (;;) {
if (ctx.hasOutboundByteBuffer()) {
msgBuf = false;
executor = ctx.executor();
break;
}
if (ctx.hasOutboundMessageBuffer()) { if (ctx.hasOutboundMessageBuffer()) {
msgBuf = true; msgBuf = true;
executor = ctx.executor(); executor = ctx.executor();
break; break;
} }
if (message instanceof ByteBuf && ctx.hasOutboundByteBuffer()) { ctx = ctx.prev;
}
} else {
msgBuf = true;
for (;;) {
if (ctx.hasOutboundMessageBuffer()) {
executor = ctx.executor(); executor = ctx.executor();
break; break;
} }
ctx = ctx.prev; ctx = ctx.prev;
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()));
}
} }
} }
@ -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);
} }
}); });