Skip to content

Instantly share code, notes, and snippets.

@trustin
Created July 3, 2012 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save trustin/3039082 to your computer and use it in GitHub Desktop.
Save trustin/3039082 to your computer and use it in GitHub Desktop.
public void inboundBufferUpdated(ChannelHandlerContext ctx) {
if (ctx.hasInboundByteBuffer()) {
ByteBuf buf = ctx.inboundByteBuffer();
...
} else {
Queue<MyMessage> buf = ctx.inboundMessageBuffer();
for (;;) {
MyMessage msg = buf.poll();
if (buf == null) {
break;
}
...
}
}
}
@menacher
Copy link

The null check should be on the "msg", not the "buf" variable. See modified gist at https://gist.github.com/3549486

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment