Allow to construct EmbeddedChannel without a ChannelHandler

Motivation:

In 4.1 and master branch we allow to construct an EmbeddedChannel without ChannelHandlers, we should do the same in 4.0.

Modifications:

Backport behavoir.

Result:

It's now possible to construct an EmbeddedChannel without any ChannelHandler
This commit is contained in:
Norman Maurer 2015-07-13 14:40:23 +02:00
parent 71ca9355dc
commit 9e8edb3093
2 changed files with 12 additions and 12 deletions

View File

@ -70,14 +70,6 @@ public class EmbeddedChannel extends AbstractChannel {
throw new NullPointerException("handlers");
}
int nHandlers = 0;
for (ChannelHandler h: handlers) {
if (h == null) {
break;
}
nHandlers ++;
}
ChannelPipeline p = pipeline();
p.addLast(new ChannelInitializer<Channel>() {
@Override
@ -92,10 +84,6 @@ public class EmbeddedChannel extends AbstractChannel {
}
});
if (nHandlers == 0) {
throw new IllegalArgumentException("handlers is empty.");
}
ChannelFuture future = loop.register(this);
assert future.isDone();
p.addLast(new LastInboundHandler());

View File

@ -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());
}
}