Skip to content

Commit 4ab3422

Browse files
committed
netty: Use DefaultELG with LocalChannel in test
LocalChannel is not guaranteed to be compatible with NioEventLoopGroup, and is failing with Netty 4.2.0.Alpha3-SNAPSHOT. See #11447
1 parent 0d47f5b commit 4ab3422

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
import io.netty.channel.ChannelHandlerContext;
8383
import io.netty.channel.ChannelOption;
8484
import io.netty.channel.ChannelPromise;
85+
import io.netty.channel.DefaultEventLoopGroup;
8586
import io.netty.channel.EventLoopGroup;
8687
import io.netty.channel.ReflectiveChannelFactory;
8788
import io.netty.channel.local.LocalChannel;
@@ -519,15 +520,20 @@ public void channelFactoryShouldSetSocketOptionKeepAlive() throws Exception {
519520
@Test
520521
public void channelFactoryShouldNNotSetSocketOptionKeepAlive() throws Exception {
521522
startServer();
522-
NettyClientTransport transport = newTransport(newNegotiator(),
523-
DEFAULT_MAX_MESSAGE_SIZE, GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE, "testUserAgent", true,
524-
TimeUnit.SECONDS.toNanos(10L), TimeUnit.SECONDS.toNanos(1L),
525-
new ReflectiveChannelFactory<>(LocalChannel.class), group);
523+
DefaultEventLoopGroup group = new DefaultEventLoopGroup(1);
524+
try {
525+
NettyClientTransport transport = newTransport(newNegotiator(),
526+
DEFAULT_MAX_MESSAGE_SIZE, GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE, "testUserAgent", true,
527+
TimeUnit.SECONDS.toNanos(10L), TimeUnit.SECONDS.toNanos(1L),
528+
new ReflectiveChannelFactory<>(LocalChannel.class), group);
526529

527-
callMeMaybe(transport.start(clientTransportListener));
530+
callMeMaybe(transport.start(clientTransportListener));
528531

529-
assertThat(transport.channel().config().getOption(ChannelOption.SO_KEEPALIVE))
530-
.isNull();
532+
assertThat(transport.channel().config().getOption(ChannelOption.SO_KEEPALIVE))
533+
.isNull();
534+
} finally {
535+
group.shutdownGracefully(0, 10, TimeUnit.SECONDS);
536+
}
531537
}
532538

533539
@Test

0 commit comments

Comments
 (0)