ByteToMessageDecoder.handlerRemoved(...) should only call fireChannelReadComplete() if fireChannelRead(...) was called before (#9211)
Motivation: At the moment ByteToMessageDecoder always calls fireChannelReadComplete() when the handler is removed from the pipeline and the cumulation buffer is not null. We should only call it when we also call fireChannelRead(...), which only happens if the cumulation buffer is not null and readable. Modifications: Only call fireChannelReadComplete() if fireChannelRead(...) is called before during removal of the handler. Result: More correct semantics
This commit is contained in:
parent
ec69da9afb
commit
b91889c3db
@ -241,18 +241,16 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
|
||||
if (buf != null) {
|
||||
// Directly set this to null so we are sure we not access it in any other method here anymore.
|
||||
cumulation = null;
|
||||
|
||||
numReads = 0;
|
||||
int readable = buf.readableBytes();
|
||||
if (readable > 0) {
|
||||
ByteBuf bytes = buf.readBytes(readable);
|
||||
buf.release();
|
||||
ctx.fireChannelRead(bytes);
|
||||
ctx.fireChannelReadComplete();
|
||||
} else {
|
||||
buf.release();
|
||||
}
|
||||
|
||||
numReads = 0;
|
||||
ctx.fireChannelReadComplete();
|
||||
}
|
||||
handlerRemoved0(ctx);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user