diff --git a/transport/src/main/java/io/netty/channel/pool/FixedChannelPool.java b/transport/src/main/java/io/netty/channel/pool/FixedChannelPool.java index f3f697c187..3b3c11195b 100644 --- a/transport/src/main/java/io/netty/channel/pool/FixedChannelPool.java +++ b/transport/src/main/java/io/netty/channel/pool/FixedChannelPool.java @@ -194,7 +194,7 @@ public class FixedChannelPool extends SimpleChannelPool { } else if (action == null && acquireTimeoutMillis != -1) { throw new NullPointerException("action"); } else if (action != null && acquireTimeoutMillis < 0) { - throw new IllegalArgumentException("acquireTimeoutMillis: " + acquireTimeoutMillis + " (expected: >= 1)"); + throw new IllegalArgumentException("acquireTimeoutMillis: " + acquireTimeoutMillis + " (expected: >= 0)"); } else { acquireTimeoutNanos = TimeUnit.MILLISECONDS.toNanos(acquireTimeoutMillis); switch (action) { diff --git a/transport/src/test/java/io/netty/channel/pool/FixedChannelPoolTest.java b/transport/src/test/java/io/netty/channel/pool/FixedChannelPoolTest.java index f667ea2a72..bbf1debeac 100644 --- a/transport/src/test/java/io/netty/channel/pool/FixedChannelPoolTest.java +++ b/transport/src/test/java/io/netty/channel/pool/FixedChannelPoolTest.java @@ -20,7 +20,6 @@ import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelInitializer; -import io.netty.channel.DefaultEventLoopGroup; import io.netty.channel.EventLoopGroup; import io.netty.channel.local.LocalAddress; import io.netty.channel.local.LocalChannel; @@ -98,6 +97,15 @@ public class FixedChannelPoolTest { @Test(expected = TimeoutException.class) public void testAcquireTimeout() throws Exception { + testAcquireTimeout(500); + } + + @Test(expected = TimeoutException.class) + public void testAcquireWithZeroTimeout() throws Exception { + testAcquireTimeout(0); + } + + private static void testAcquireTimeout(long timeoutMillis) throws Exception { LocalAddress addr = new LocalAddress(LOCAL_ADDR_ID); Bootstrap cb = new Bootstrap(); cb.remoteAddress(addr); @@ -118,7 +126,7 @@ public class FixedChannelPoolTest { Channel sc = sb.bind(addr).syncUninterruptibly().channel(); ChannelPoolHandler handler = new TestChannelPoolHandler(); ChannelPool pool = new FixedChannelPool(cb, handler, ChannelHealthChecker.ACTIVE, - AcquireTimeoutAction.FAIL, 500, 1, Integer.MAX_VALUE); + AcquireTimeoutAction.FAIL, timeoutMillis, 1, Integer.MAX_VALUE); Channel channel = pool.acquire().syncUninterruptibly().getNow(); Future future = pool.acquire();