Skip to content

Commit

Permalink
netty: Use DefaultELG with LocalChannel in test
Browse files Browse the repository at this point in the history
LocalChannel is not guaranteed to be compatible with NioEventLoopGroup,
and is failing with Netty 4.2.0.Alpha3-SNAPSHOT.

See #11447
  • Loading branch information
ejona86 committed Aug 12, 2024
1 parent 0d47f5b commit 4ab3422
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPromise;
import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.ReflectiveChannelFactory;
import io.netty.channel.local.LocalChannel;
Expand Down Expand Up @@ -519,15 +520,20 @@ public void channelFactoryShouldSetSocketOptionKeepAlive() throws Exception {
@Test
public void channelFactoryShouldNNotSetSocketOptionKeepAlive() throws Exception {
startServer();
NettyClientTransport transport = newTransport(newNegotiator(),
DEFAULT_MAX_MESSAGE_SIZE, GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE, "testUserAgent", true,
TimeUnit.SECONDS.toNanos(10L), TimeUnit.SECONDS.toNanos(1L),
new ReflectiveChannelFactory<>(LocalChannel.class), group);
DefaultEventLoopGroup group = new DefaultEventLoopGroup(1);
try {
NettyClientTransport transport = newTransport(newNegotiator(),
DEFAULT_MAX_MESSAGE_SIZE, GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE, "testUserAgent", true,
TimeUnit.SECONDS.toNanos(10L), TimeUnit.SECONDS.toNanos(1L),
new ReflectiveChannelFactory<>(LocalChannel.class), group);

callMeMaybe(transport.start(clientTransportListener));
callMeMaybe(transport.start(clientTransportListener));

assertThat(transport.channel().config().getOption(ChannelOption.SO_KEEPALIVE))
.isNull();
assertThat(transport.channel().config().getOption(ChannelOption.SO_KEEPALIVE))
.isNull();
} finally {
group.shutdownGracefully(0, 10, TimeUnit.SECONDS);
}
}

@Test
Expand Down

0 comments on commit 4ab3422

Please sign in to comment.