I'm writing a decoder-handler for a binary message format which is possible to decode up to the last complete element of the message in the available bytes. So if there's an array of int64
values, you read the highest multiple of 8 bytes which is less than ByteBuf.readableBytes()
. I'm using netty 5.0.0.Alpha2.
My problem is that it looks as though Netty is discarding the unread bytes left in the ByteBuf
, rather than appending new network-bytes to them; this means that when I try to resume decoding, it fails since there are missing bytes and a corrupt stream.
Are there ChannelHandlerContext
or ByteBuf
or Channel
methods which I should be invoking to preserve those unread bytes? Or is the current/only solution to save them in a scratch space within the handler myself? I suspect that buffer-pooling is the reason why a different buffer is being used for the subsequent read.
Thanks
Michael
PS: I'm not keen on using the ReplayingDecoder
or ByteToMessageDecoder
classes as fitting my decoder library around them would be too intrusive (IMHO).