Make NoSuchBufferException message more useful

This commit is contained in:
Trustin Lee 2012-10-16 14:23:02 -07:00
parent b291d85757
commit b76c39318d
4 changed files with 25 additions and 3 deletions

View File

@ -117,6 +117,28 @@ final class CodecUtil {
return false;
}
static void addToNextOutboundBuffer(ChannelHandlerContext ctx, Object msg) {
try {
ctx.nextOutboundMessageBuffer().add(msg);
} catch (NoSuchBufferException e) {
NoSuchBufferException newE =
new NoSuchBufferException(e.getMessage() + " (msg: " + msg + ')');
newE.setStackTrace(e.getStackTrace());
throw newE;
}
}
static void addToNextInboundBuffer(ChannelHandlerContext ctx, Object msg) {
try {
ctx.nextInboundMessageBuffer().add(msg);
} catch (NoSuchBufferException e) {
NoSuchBufferException newE =
new NoSuchBufferException(e.getMessage() + " (msg: " + msg + ')');
newE.setStackTrace(e.getStackTrace());
throw newE;
}
}
private CodecUtil() {
// Unused
}

View File

@ -41,7 +41,7 @@ public abstract class MessageToByteEncoder<I> extends ChannelOutboundMessageHand
}
if (!isEncodable(msg)) {
ctx.nextOutboundMessageBuffer().add(msg);
CodecUtil.addToNextOutboundBuffer(ctx, msg);
continue;
}

View File

@ -47,7 +47,7 @@ public abstract class MessageToMessageDecoder<I, O>
break;
}
if (!isDecodable(msg)) {
ctx.nextInboundMessageBuffer().add(msg);
CodecUtil.addToNextInboundBuffer(ctx, msg);
notify = true;
continue;
}

View File

@ -39,7 +39,7 @@ public abstract class MessageToMessageEncoder<I, O> extends ChannelOutboundMessa
}
if (!isEncodable(msg)) {
ctx.nextOutboundMessageBuffer().add(msg);
CodecUtil.addToNextOutboundBuffer(ctx, msg);
continue;
}