Fix regression introduced by 11f9e9084b2da5e7a0e48c6a5c86be0f41a584de
Motivation: While cherry-picked 11f9e9084b2da5e7a0e48c6a5c86be0f41a584de I changed the EmbeddedChannel implementation to not allow no ChannelHandlers when constructing it. This was done by mistake. Modifications: Revert change and add unit test. Result: Restore old behavior.
This commit is contained in:
parent
d43569fce6
commit
a99e29e032
@ -82,18 +82,6 @@ public class EmbeddedChannel extends AbstractChannel {
|
||||
throw new NullPointerException("handlers");
|
||||
}
|
||||
|
||||
int nHandlers = 0;
|
||||
for (ChannelHandler h: handlers) {
|
||||
if (h == null) {
|
||||
break;
|
||||
}
|
||||
nHandlers ++;
|
||||
}
|
||||
|
||||
if (nHandlers == 0) {
|
||||
throw new IllegalArgumentException("handlers is empty.");
|
||||
}
|
||||
|
||||
ChannelPipeline p = pipeline();
|
||||
p.addLast(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
|
@ -122,4 +122,16 @@ public class EmbeddedChannelTest {
|
||||
throw cause;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructWithOutHandler() {
|
||||
EmbeddedChannel channel = new EmbeddedChannel();
|
||||
Assert.assertTrue(channel.writeInbound(1));
|
||||
Assert.assertTrue(channel.writeOutbound(2));
|
||||
Assert.assertTrue(channel.finish());
|
||||
Assert.assertSame(1, channel.readInbound());
|
||||
Assert.assertNull(channel.readInbound());
|
||||
Assert.assertSame(2, channel.readOutbound());
|
||||
Assert.assertNull(channel.readOutbound());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user