-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
remove handler cause ByteToMessageDecoder out disorder #9668
Copy link
Copy link
Closed
Milestone
Description
remove handler cause ByteToMessageDecoder out disorder
I input byte stream [1,2,3,4,5], when i read `4` then remove ByteToMessageDecoder,
the out is stream [1,2,3,5,4]
Here are the test cases,the cases will fail
@Test
public void testDisorder(){
ByteToMessageDecoder decoder = new ByteToMessageDecoder() {
int count = 0;
//read 4 byte then remove this decoder
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
out.add(in.readBytes(1));
if (++count >= 4) {
ctx.pipeline().remove(this);
}
}
};
EmbeddedChannel channel = new EmbeddedChannel(decoder);
assertTrue(channel.writeInbound(Unpooled.wrappedBuffer(new byte[]{1, 2, 3, 4, 5})));
assertEquals(1, ((ByteBuf) channel.readInbound()).readByte());
assertEquals(2, ((ByteBuf) channel.readInbound()).readByte());
assertEquals(3, ((ByteBuf) channel.readInbound()).readByte());
assertEquals(4, ((ByteBuf) channel.readInbound()).readByte());
assertEquals(5, ((ByteBuf) channel.readInbound()).readByte());
assertFalse(channel.finish());
}
netty 4.1
java8
window10
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels