Fix regression introduced by 11f9e9084b

Motivation:

While cherry-picked 11f9e9084b 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:
Norman Maurer 2015-07-08 21:37:58 +02:00
parent d43569fce6
commit a99e29e032
2 changed files with 12 additions and 12 deletions

View File

@ -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

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