From f66093cf2c83a8296a05669053bfd52c5374d9d2 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Wed, 10 Jun 2026 15:49:15 -0700 Subject: [PATCH 1/3] Upgrade to Netty 4.2.15 Netty 4.2 has the thread classes interact in a new way, so they've deprecated the Netty 4.1 threading APIs. While we want to use Netty 4.2, not all build systems compiling gRPC may have upgraded to 4.2 yet, so let's not begin using Netty 4.2 APIs yet. --- MODULE.bazel | 24 +++++++++---------- .../grpc/alts/HandshakerServiceChannel.java | 5 ++-- .../grpc/benchmarks/TransportBenchmark.java | 4 ++-- .../benchmarks/netty/AbstractBenchmark.java | 16 +++++++++---- .../main/java/io/grpc/benchmarks/Utils.java | 16 +++++++++---- .../io/grpc/benchmarks/driver/LoadWorker.java | 13 +++++----- .../io/grpc/benchmarks/qps/AsyncServer.java | 9 ++++--- gradle/libs.versions.toml | 8 +++---- .../integration/AltsHandshakerTest.java | 13 ++++++---- .../Http2NettyLocalChannelTest.java | 5 ++-- .../grpc/testing/integration/RetryTest.java | 7 +++--- netty/src/main/java/io/grpc/netty/Utils.java | 6 +++-- .../grpc/netty/NettyClientTransportTest.java | 8 +++---- .../java/io/grpc/netty/NettyServerTest.java | 4 ++-- .../grpc/netty/ProtocolNegotiatorsTest.java | 22 ++++++++++------- .../netty/UdsNettyChannelProviderTest.java | 9 ++++--- repositories.bzl | 24 +++++++++---------- 17 files changed, 114 insertions(+), 79 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 85f12a58609..f0d7a48fac1 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -25,20 +25,20 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [ "dev.cel:common:0.12.0", "com.squareup.okhttp:okhttp:2.7.5", "com.squareup.okio:okio:2.10.0", # 3.0+ needs swapping to -jvm; need work to avoid flag-day - "io.netty:netty-buffer:4.1.135.Final", - "io.netty:netty-codec-http2:4.1.135.Final", - "io.netty:netty-codec-http:4.1.135.Final", - "io.netty:netty-codec-socks:4.1.135.Final", - "io.netty:netty-codec:4.1.135.Final", - "io.netty:netty-common:4.1.135.Final", - "io.netty:netty-handler-proxy:4.1.135.Final", - "io.netty:netty-handler:4.1.135.Final", - "io.netty:netty-resolver:4.1.135.Final", + "io.netty:netty-buffer:4.2.15.Final", + "io.netty:netty-codec-http2:4.2.15.Final", + "io.netty:netty-codec-http:4.2.15.Final", + "io.netty:netty-codec-socks:4.2.15.Final", + "io.netty:netty-codec:4.2.15.Final", + "io.netty:netty-common:4.2.15.Final", + "io.netty:netty-handler-proxy:4.2.15.Final", + "io.netty:netty-handler:4.2.15.Final", + "io.netty:netty-resolver:4.2.15.Final", "io.netty:netty-tcnative-boringssl-static:2.0.75.Final", "io.netty:netty-tcnative-classes:2.0.75.Final", - "io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.135.Final", - "io.netty:netty-transport-native-unix-common:4.1.135.Final", - "io.netty:netty-transport:4.1.135.Final", + "io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.2.15.Final", + "io.netty:netty-transport-native-unix-common:4.2.15.Final", + "io.netty:netty-transport:4.2.15.Final", "io.opencensus:opencensus-api:0.31.0", "io.opencensus:opencensus-contrib-grpc-metrics:0.31.0", "io.perfmark:perfmark-api:0.27.0", diff --git a/alts/src/main/java/io/grpc/alts/HandshakerServiceChannel.java b/alts/src/main/java/io/grpc/alts/HandshakerServiceChannel.java index 5e32d22d901..c914385a451 100644 --- a/alts/src/main/java/io/grpc/alts/HandshakerServiceChannel.java +++ b/alts/src/main/java/io/grpc/alts/HandshakerServiceChannel.java @@ -25,7 +25,6 @@ import io.grpc.internal.SharedResourceHolder.Resource; import io.grpc.netty.NettyChannelBuilder; import io.netty.channel.EventLoopGroup; -import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.util.concurrent.DefaultThreadFactory; import java.net.InetSocketAddress; @@ -78,8 +77,10 @@ public ChannelResource(String target) { @Override public Channel create() { /* Use its own event loop thread pool to avoid blocking. */ + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API EventLoopGroup eventGroup = - new NioEventLoopGroup(1, new DefaultThreadFactory("handshaker pool", true)); + new io.netty.channel.nio.NioEventLoopGroup( + 1, new DefaultThreadFactory("handshaker pool", true)); NettyChannelBuilder channelBuilder = NettyChannelBuilder.forTarget(target) .channelType(NioSocketChannel.class, InetSocketAddress.class) diff --git a/benchmarks/src/jmh/java/io/grpc/benchmarks/TransportBenchmark.java b/benchmarks/src/jmh/java/io/grpc/benchmarks/TransportBenchmark.java index d0de1571a59..8c0ef187fbb 100644 --- a/benchmarks/src/jmh/java/io/grpc/benchmarks/TransportBenchmark.java +++ b/benchmarks/src/jmh/java/io/grpc/benchmarks/TransportBenchmark.java @@ -41,7 +41,6 @@ import io.grpc.okhttp.OkHttpChannelBuilder; import io.grpc.stub.StreamObserver; import io.netty.channel.Channel; -import io.netty.channel.DefaultEventLoopGroup; import io.netty.channel.EventLoopGroup; import io.netty.channel.ServerChannel; import io.netty.channel.local.LocalAddress; @@ -103,7 +102,8 @@ public void setUp() throws Exception { case NETTY_LOCAL: { String name = "bench" + Math.random(); LocalAddress address = new LocalAddress(name); - EventLoopGroup group = new DefaultEventLoopGroup(); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + EventLoopGroup group = new io.netty.channel.DefaultEventLoopGroup(); serverBuilder = NettyServerBuilder.forAddress(address, serverCreds) .bossEventLoopGroup(group) .workerEventLoopGroup(group) diff --git a/benchmarks/src/jmh/java/io/grpc/benchmarks/netty/AbstractBenchmark.java b/benchmarks/src/jmh/java/io/grpc/benchmarks/netty/AbstractBenchmark.java index 6d8a9ec8a8e..ffda287764d 100644 --- a/benchmarks/src/jmh/java/io/grpc/benchmarks/netty/AbstractBenchmark.java +++ b/benchmarks/src/jmh/java/io/grpc/benchmarks/netty/AbstractBenchmark.java @@ -41,7 +41,6 @@ import io.netty.channel.local.LocalAddress; import io.netty.channel.local.LocalChannel; import io.netty.channel.local.LocalServerChannel; -import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.util.concurrent.DefaultThreadFactory; @@ -229,8 +228,14 @@ public void setup(ExecutorType clientExecutor, // Always use a different worker group from the client. ThreadFactory serverThreadFactory = new DefaultThreadFactory("STF pool", true /* daemon */); - serverBuilder.workerEventLoopGroup(new NioEventLoopGroup(0, serverThreadFactory)); - serverBuilder.bossEventLoopGroup(new NioEventLoopGroup(1, serverThreadFactory)); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + io.netty.channel.EventLoopGroup workerGroup = + new io.netty.channel.nio.NioEventLoopGroup(0, serverThreadFactory); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + io.netty.channel.EventLoopGroup bossGroup = + new io.netty.channel.nio.NioEventLoopGroup(1, serverThreadFactory); + serverBuilder.workerEventLoopGroup(workerGroup); + serverBuilder.bossEventLoopGroup(bossGroup); // Always set connection and stream window size to same value serverBuilder.flowControlWindow(windowSize.bytes()); @@ -388,8 +393,11 @@ public void onReady() { ThreadFactory clientThreadFactory = new DefaultThreadFactory("CTF pool", true /* daemon */); for (int i = 0; i < channelCount; i++) { // Use a dedicated event-loop for each channel + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + io.netty.channel.EventLoopGroup elg = + new io.netty.channel.nio.NioEventLoopGroup(1, clientThreadFactory); channels[i] = channelBuilder - .eventLoopGroup(new NioEventLoopGroup(1, clientThreadFactory)) + .eventLoopGroup(elg) .build(); } } diff --git a/benchmarks/src/main/java/io/grpc/benchmarks/Utils.java b/benchmarks/src/main/java/io/grpc/benchmarks/Utils.java index c4ba99e1639..9d678761133 100644 --- a/benchmarks/src/main/java/io/grpc/benchmarks/Utils.java +++ b/benchmarks/src/main/java/io/grpc/benchmarks/Utils.java @@ -35,9 +35,7 @@ import io.grpc.okhttp.OkHttpChannelBuilder; import io.grpc.testing.TlsTesting; import io.netty.channel.epoll.EpollDomainSocketChannel; -import io.netty.channel.epoll.EpollEventLoopGroup; import io.netty.channel.epoll.EpollSocketChannel; -import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.channel.unix.DomainSocketAddress; import io.netty.util.concurrent.DefaultThreadFactory; @@ -128,22 +126,30 @@ private static NettyChannelBuilder configureNetty( DefaultThreadFactory tf = new DefaultThreadFactory("client-elg-", true /*daemon */); switch (transport) { case NETTY_NIO: + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + io.netty.channel.EventLoopGroup elg = new io.netty.channel.nio.NioEventLoopGroup(0, tf); builder - .eventLoopGroup(new NioEventLoopGroup(0, tf)) + .eventLoopGroup(elg) .channelType(NioSocketChannel.class, InetSocketAddress.class); break; case NETTY_EPOLL: // These classes only work on Linux. + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + io.netty.channel.EventLoopGroup epollElg = + new io.netty.channel.epoll.EpollEventLoopGroup(0, tf); builder - .eventLoopGroup(new EpollEventLoopGroup(0, tf)) + .eventLoopGroup(epollElg) .channelType(EpollSocketChannel.class, InetSocketAddress.class); break; case NETTY_UNIX_DOMAIN_SOCKET: // These classes only work on Linux. + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + io.netty.channel.EventLoopGroup unixElg = + new io.netty.channel.epoll.EpollEventLoopGroup(0, tf); builder - .eventLoopGroup(new EpollEventLoopGroup(0, tf)) + .eventLoopGroup(unixElg) .channelType(EpollDomainSocketChannel.class, DomainSocketAddress.class); break; diff --git a/benchmarks/src/main/java/io/grpc/benchmarks/driver/LoadWorker.java b/benchmarks/src/main/java/io/grpc/benchmarks/driver/LoadWorker.java index 63fbef0cabe..75b51b3b2e5 100644 --- a/benchmarks/src/main/java/io/grpc/benchmarks/driver/LoadWorker.java +++ b/benchmarks/src/main/java/io/grpc/benchmarks/driver/LoadWorker.java @@ -27,7 +27,6 @@ import io.grpc.benchmarks.proto.WorkerServiceGrpc; import io.grpc.netty.NettyServerBuilder; import io.grpc.stub.StreamObserver; -import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioServerSocketChannel; import java.util.logging.Level; import java.util.logging.Logger; @@ -45,11 +44,13 @@ public class LoadWorker { LoadWorker(int driverPort, int serverPort) throws Exception { this.serverPort = serverPort; - NioEventLoopGroup singleThreadGroup = new NioEventLoopGroup(1, - new ThreadFactoryBuilder() - .setDaemon(true) - .setNameFormat("load-worker-%d") - .build()); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + io.netty.channel.EventLoopGroup singleThreadGroup = + new io.netty.channel.nio.NioEventLoopGroup(1, + new ThreadFactoryBuilder() + .setDaemon(true) + .setNameFormat("load-worker-%d") + .build()); this.driverServer = NettyServerBuilder.forPort(driverPort, InsecureServerCredentials.create()) .directExecutor() .channelType(NioServerSocketChannel.class) diff --git a/benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncServer.java b/benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncServer.java index 7f61e15f783..9c7455ac45b 100644 --- a/benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncServer.java +++ b/benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncServer.java @@ -29,7 +29,6 @@ import io.grpc.testing.TlsTesting; import io.netty.channel.EventLoopGroup; import io.netty.channel.ServerChannel; -import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.util.concurrent.DefaultThreadFactory; import java.io.IOException; @@ -94,8 +93,12 @@ static Server newServer(ServerConfiguration config) throws IOException { ThreadFactory tf = new DefaultThreadFactory("server-elg-", true /*daemon */); switch (config.transport) { case NETTY_NIO: { - boss = new NioEventLoopGroup(1, tf); - worker = new NioEventLoopGroup(0, tf); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + EventLoopGroup nioBoss = new io.netty.channel.nio.NioEventLoopGroup(1, tf); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + EventLoopGroup nioWorker = new io.netty.channel.nio.NioEventLoopGroup(0, tf); + boss = nioBoss; + worker = nioWorker; channelType = NioServerSocketChannel.class; break; } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 459522623b9..91f71a40733 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -104,17 +104,17 @@ mockito-android = "org.mockito:mockito-android:4.4.0" mockito-core = "org.mockito:mockito-core:4.4.0" # Need to decide when we require users to absorb the breaking changes in 4.2 # checkForUpdates: netty-codec-http2:4.1.+ -netty-codec-http2 = "io.netty:netty-codec-http2:4.1.135.Final" +netty-codec-http2 = "io.netty:netty-codec-http2:4.2.15.Final" # checkForUpdates: netty-handler-proxy:4.1.+ -netty-handler-proxy = "io.netty:netty-handler-proxy:4.1.135.Final" +netty-handler-proxy = "io.netty:netty-handler-proxy:4.2.15.Final" # Keep the following references of tcnative version in sync whenever it's updated: # SECURITY.md netty-tcnative = "io.netty:netty-tcnative-boringssl-static:2.0.75.Final" netty-tcnative-classes = "io.netty:netty-tcnative-classes:2.0.75.Final" # checkForUpdates: netty-transport-epoll:4.1.+ -netty-transport-epoll = "io.netty:netty-transport-native-epoll:4.1.135.Final" +netty-transport-epoll = "io.netty:netty-transport-native-epoll:4.2.15.Final" # checkForUpdates: netty-unix-common:4.1.+ -netty-unix-common = "io.netty:netty-transport-native-unix-common:4.1.135.Final" +netty-unix-common = "io.netty:netty-transport-native-unix-common:4.2.15.Final" okhttp = "com.squareup.okhttp:okhttp:2.7.5" # okio 3.5+ uses Kotlin 1.9+ which requires Android Gradle Plugin 9+ # checkForUpdates: okio:3.4.+ diff --git a/interop-testing/src/test/java/io/grpc/testing/integration/AltsHandshakerTest.java b/interop-testing/src/test/java/io/grpc/testing/integration/AltsHandshakerTest.java index c6c1d2b3e7e..d59512723d9 100644 --- a/interop-testing/src/test/java/io/grpc/testing/integration/AltsHandshakerTest.java +++ b/interop-testing/src/test/java/io/grpc/testing/integration/AltsHandshakerTest.java @@ -32,7 +32,6 @@ import io.grpc.testing.integration.Messages.Payload; import io.grpc.testing.integration.Messages.SimpleRequest; import io.grpc.testing.integration.Messages.SimpleResponse; -import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.util.concurrent.DefaultThreadFactory; import org.junit.Before; @@ -71,11 +70,15 @@ public void unaryCall(SimpleRequest request, StreamObserver so) public void setup() throws Exception { // create new EventLoopGroups to avoid deadlock at server side handshake negotiation, e.g. // happens when handshakerServer and testServer child channels are on the same eventloop. + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + io.netty.channel.EventLoopGroup bossGroup = + new io.netty.channel.nio.NioEventLoopGroup(0, new DefaultThreadFactory("test-alts-boss")); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + io.netty.channel.EventLoopGroup workerGroup = + new io.netty.channel.nio.NioEventLoopGroup(0, new DefaultThreadFactory("test-alts-worker")); handshakerServer = grpcCleanup.register(NettyServerBuilder.forPort(0) - .bossEventLoopGroup( - new NioEventLoopGroup(0, new DefaultThreadFactory("test-alts-boss"))) - .workerEventLoopGroup( - new NioEventLoopGroup(0, new DefaultThreadFactory("test-alts-worker"))) + .bossEventLoopGroup(bossGroup) + .workerEventLoopGroup(workerGroup) .channelType(NioServerSocketChannel.class) .addService(new AltsHandshakerTestService()) .build()).start(); diff --git a/interop-testing/src/test/java/io/grpc/testing/integration/Http2NettyLocalChannelTest.java b/interop-testing/src/test/java/io/grpc/testing/integration/Http2NettyLocalChannelTest.java index 6659af68ae0..30c5bf52770 100644 --- a/interop-testing/src/test/java/io/grpc/testing/integration/Http2NettyLocalChannelTest.java +++ b/interop-testing/src/test/java/io/grpc/testing/integration/Http2NettyLocalChannelTest.java @@ -22,7 +22,7 @@ import io.grpc.netty.NegotiationType; import io.grpc.netty.NettyChannelBuilder; import io.grpc.netty.NettyServerBuilder; -import io.netty.channel.DefaultEventLoopGroup; +import io.netty.channel.EventLoopGroup; import io.netty.channel.local.LocalAddress; import io.netty.channel.local.LocalChannel; import io.netty.channel.local.LocalServerChannel; @@ -36,7 +36,8 @@ @RunWith(JUnit4.class) public class Http2NettyLocalChannelTest extends AbstractInteropTest { - private DefaultEventLoopGroup eventLoopGroup = new DefaultEventLoopGroup(); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + private EventLoopGroup eventLoopGroup = new io.netty.channel.DefaultEventLoopGroup(); @Override protected ServerBuilder getServerBuilder() { diff --git a/interop-testing/src/test/java/io/grpc/testing/integration/RetryTest.java b/interop-testing/src/test/java/io/grpc/testing/integration/RetryTest.java index 669ce1c69db..fbdba498d3d 100644 --- a/interop-testing/src/test/java/io/grpc/testing/integration/RetryTest.java +++ b/interop-testing/src/test/java/io/grpc/testing/integration/RetryTest.java @@ -59,7 +59,6 @@ import io.grpc.netty.NettyChannelBuilder; import io.grpc.netty.NettyServerBuilder; import io.grpc.testing.GrpcCleanupRule; -import io.netty.channel.DefaultEventLoopGroup; import io.netty.channel.EventLoopGroup; import io.netty.channel.local.LocalAddress; import io.netty.channel.local.LocalChannel; @@ -111,7 +110,8 @@ public class RetryTest { mock(ClientCall.Listener.class, delegatesTo(testCallListener)); private CountDownLatch backoffLatch = new CountDownLatch(1); - private final EventLoopGroup clientGroup = new DefaultEventLoopGroup(1) { + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + private final EventLoopGroup clientGroup = new io.netty.channel.DefaultEventLoopGroup(1) { @SuppressWarnings("FutureReturnValueIgnored") @Override public ScheduledFuture schedule( @@ -138,7 +138,8 @@ public void run() {} // no-op TimeUnit.NANOSECONDS); } }; - private final EventLoopGroup serverGroup = new DefaultEventLoopGroup(1); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + private final EventLoopGroup serverGroup = new io.netty.channel.DefaultEventLoopGroup(1); private final FakeStatsRecorder clientStatsRecorder = new FakeStatsRecorder(); private final ClientInterceptor statsInterceptor = InternalCensusStatsAccessor.getClientInterceptor( diff --git a/netty/src/main/java/io/grpc/netty/Utils.java b/netty/src/main/java/io/grpc/netty/Utils.java index 386df20ba0b..1d30a19c727 100644 --- a/netty/src/main/java/io/grpc/netty/Utils.java +++ b/netty/src/main/java/io/grpc/netty/Utils.java @@ -47,7 +47,6 @@ import io.netty.channel.EventLoopGroup; import io.netty.channel.ReflectiveChannelFactory; import io.netty.channel.ServerChannel; -import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.handler.codec.DecoderException; @@ -513,7 +512,10 @@ public EventLoopGroup create() { ThreadFactory threadFactory = new DefaultThreadFactory(name, /* daemon= */ true); switch (eventLoopGroupType) { case NIO: - return new NioEventLoopGroup(numEventLoops, threadFactory); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + EventLoopGroup group = + new io.netty.channel.nio.NioEventLoopGroup(numEventLoops, threadFactory); + return group; case EPOLL: return createEpollEventLoopGroup(numEventLoops, threadFactory); default: diff --git a/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java b/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java index 268be0afa7e..ef8d2e5efda 100644 --- a/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java +++ b/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java @@ -90,11 +90,9 @@ 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; -import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannelConfig; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; @@ -163,7 +161,8 @@ public class NettyClientTransportTest { private final List transports = new ArrayList<>(); private final LinkedBlockingQueue serverTransportAttributesList = new LinkedBlockingQueue<>(); - private final NioEventLoopGroup group = new NioEventLoopGroup(1); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + private final EventLoopGroup group = new io.netty.channel.nio.NioEventLoopGroup(1); private final EchoServerListener serverListener = new EchoServerListener(); private final InternalChannelz channelz = new InternalChannelz(); private Runnable tooManyPingsRunnable = new Runnable() { @@ -591,7 +590,8 @@ public void channelFactoryShouldSetSocketOptionKeepAlive() throws Exception { @Test public void channelFactoryShouldNNotSetSocketOptionKeepAlive() throws Exception { startServer(); - DefaultEventLoopGroup group = new DefaultEventLoopGroup(1); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + EventLoopGroup group = new io.netty.channel.DefaultEventLoopGroup(1); try { NettyClientTransport transport = newTransport(newNegotiator(), DEFAULT_MAX_MESSAGE_SIZE, GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE, "testUserAgent", true, diff --git a/netty/src/test/java/io/grpc/netty/NettyServerTest.java b/netty/src/test/java/io/grpc/netty/NettyServerTest.java index 61c3f9e219e..e81008d029e 100644 --- a/netty/src/test/java/io/grpc/netty/NettyServerTest.java +++ b/netty/src/test/java/io/grpc/netty/NettyServerTest.java @@ -56,7 +56,6 @@ import io.netty.channel.EventLoopGroup; import io.netty.channel.ReflectiveChannelFactory; import io.netty.channel.WriteBufferWaterMark; -import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.util.AsciiString; import io.netty.util.concurrent.Future; @@ -88,7 +87,8 @@ public class NettyServerTest { @Rule public final MockitoRule mocks = MockitoJUnit.rule(); private final InternalChannelz channelz = new InternalChannelz(); - private final NioEventLoopGroup eventLoop = new NioEventLoopGroup(1); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + private final EventLoopGroup eventLoop = new io.netty.channel.nio.NioEventLoopGroup(1); private final ChannelFactory channelFactory = new ReflectiveChannelFactory<>(NioServerSocketChannel.class); diff --git a/netty/src/test/java/io/grpc/netty/ProtocolNegotiatorsTest.java b/netty/src/test/java/io/grpc/netty/ProtocolNegotiatorsTest.java index 403b1b64329..8845a3986b9 100644 --- a/netty/src/test/java/io/grpc/netty/ProtocolNegotiatorsTest.java +++ b/netty/src/test/java/io/grpc/netty/ProtocolNegotiatorsTest.java @@ -90,7 +90,6 @@ import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPromise; import io.netty.channel.DefaultEventLoop; -import io.netty.channel.DefaultEventLoopGroup; import io.netty.channel.EventLoopGroup; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.channel.local.LocalAddress; @@ -919,7 +918,8 @@ public String applicationProtocol() { return "h2"; } }; - DefaultEventLoopGroup elg = new DefaultEventLoopGroup(1); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + EventLoopGroup elg = new io.netty.channel.DefaultEventLoopGroup(1); ClientTlsHandler handler = new ClientTlsHandler(grpcHandler, sslContext, "authority", elg, noopLogger, Optional.absent(), @@ -945,7 +945,8 @@ public String applicationProtocol() { return "managed_mtls"; } }; - DefaultEventLoopGroup elg = new DefaultEventLoopGroup(1); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + EventLoopGroup elg = new io.netty.channel.DefaultEventLoopGroup(1); InputStream clientCert = TlsTesting.loadCert("client.pem"); InputStream key = TlsTesting.loadCert("client.key"); @@ -983,7 +984,8 @@ public String applicationProtocol() { return "badproto"; } }; - DefaultEventLoopGroup elg = new DefaultEventLoopGroup(1); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + EventLoopGroup elg = new io.netty.channel.DefaultEventLoopGroup(1); ClientTlsHandler handler = new ClientTlsHandler(grpcHandler, sslContext, "authority", elg, noopLogger, Optional.absent(), @@ -1113,7 +1115,8 @@ public void httpProxy_nullUserPassNoException() throws Exception { @Test public void httpProxy_completes() throws Exception { - DefaultEventLoopGroup elg = new DefaultEventLoopGroup(1); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + EventLoopGroup elg = new io.netty.channel.DefaultEventLoopGroup(1); // ProxyHandler is incompatible with EmbeddedChannel because when channelRegistered() is called // the channel is already active. LocalAddress proxy = new LocalAddress("httpProxy_completes"); @@ -1176,7 +1179,8 @@ public void httpProxy_completes() throws Exception { @Test public void httpProxy_500() throws Exception { - DefaultEventLoopGroup elg = new DefaultEventLoopGroup(1); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + EventLoopGroup elg = new io.netty.channel.DefaultEventLoopGroup(1); // ProxyHandler is incompatible with EmbeddedChannel because when channelRegistered() is called // the channel is already active. LocalAddress proxy = new LocalAddress("httpProxy_500"); @@ -1228,7 +1232,8 @@ public void httpProxy_500() throws Exception { @Test public void httpProxy_customHeaders() throws Exception { - DefaultEventLoopGroup elg = new DefaultEventLoopGroup(1); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + EventLoopGroup elg = new io.netty.channel.DefaultEventLoopGroup(1); // ProxyHandler is incompatible with EmbeddedChannel because when channelRegistered() is called // the channel is already active. LocalAddress proxy = new LocalAddress("httpProxy_customHeaders"); @@ -1299,7 +1304,8 @@ public void httpProxy_customHeaders() throws Exception { @Test public void waitUntilActiveHandler_firesNegotiation() throws Exception { - EventLoopGroup elg = new DefaultEventLoopGroup(1); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + EventLoopGroup elg = new io.netty.channel.DefaultEventLoopGroup(1); SocketAddress addr = new LocalAddress("addr"); final AtomicReference event = new AtomicReference<>(); ChannelHandler next = new ChannelInboundHandlerAdapter() { diff --git a/netty/src/test/java/io/grpc/netty/UdsNettyChannelProviderTest.java b/netty/src/test/java/io/grpc/netty/UdsNettyChannelProviderTest.java index e0c3d5a8525..f02335cb5e1 100644 --- a/netty/src/test/java/io/grpc/netty/UdsNettyChannelProviderTest.java +++ b/netty/src/test/java/io/grpc/netty/UdsNettyChannelProviderTest.java @@ -35,7 +35,6 @@ import io.grpc.testing.protobuf.SimpleResponse; import io.grpc.testing.protobuf.SimpleServiceGrpc; import io.netty.channel.EventLoopGroup; -import io.netty.channel.epoll.EpollEventLoopGroup; import io.netty.channel.epoll.EpollServerDomainSocketChannel; import io.netty.channel.unix.DomainSocketAddress; import java.io.IOException; @@ -141,8 +140,12 @@ private static String unaryRpc( } private void createUdsServer(String name) throws IOException { - elg = new EpollEventLoopGroup(); - boss = new EpollEventLoopGroup(1); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + EventLoopGroup epollElg = new io.netty.channel.epoll.EpollEventLoopGroup(); + @SuppressWarnings("deprecation") // Wait a bit before migrating to the Netty 4.2 API + EventLoopGroup epollBoss = new io.netty.channel.epoll.EpollEventLoopGroup(1); + elg = epollElg; + boss = epollBoss; cleanupRule.register( NettyServerBuilder.forAddress(new DomainSocketAddress(name)) .bossEventLoopGroup(boss) diff --git a/repositories.bzl b/repositories.bzl index 700173b2115..5dd1a3dd3fc 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -30,20 +30,20 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [ "dev.cel:common:0.12.0", "com.squareup.okhttp:okhttp:2.7.5", "com.squareup.okio:okio:2.10.0", # 3.0+ needs swapping to -jvm; need work to avoid flag-day - "io.netty:netty-buffer:4.1.135.Final", - "io.netty:netty-codec-http2:4.1.135.Final", - "io.netty:netty-codec-http:4.1.135.Final", - "io.netty:netty-codec-socks:4.1.135.Final", - "io.netty:netty-codec:4.1.135.Final", - "io.netty:netty-common:4.1.135.Final", - "io.netty:netty-handler-proxy:4.1.135.Final", - "io.netty:netty-handler:4.1.135.Final", - "io.netty:netty-resolver:4.1.135.Final", + "io.netty:netty-buffer:4.2.15.Final", + "io.netty:netty-codec-http2:4.2.15.Final", + "io.netty:netty-codec-http:4.2.15.Final", + "io.netty:netty-codec-socks:4.2.15.Final", + "io.netty:netty-codec:4.2.15.Final", + "io.netty:netty-common:4.2.15.Final", + "io.netty:netty-handler-proxy:4.2.15.Final", + "io.netty:netty-handler:4.2.15.Final", + "io.netty:netty-resolver:4.2.15.Final", "io.netty:netty-tcnative-boringssl-static:2.0.75.Final", "io.netty:netty-tcnative-classes:2.0.75.Final", - "io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.135.Final", - "io.netty:netty-transport-native-unix-common:4.1.135.Final", - "io.netty:netty-transport:4.1.135.Final", + "io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.2.15.Final", + "io.netty:netty-transport-native-unix-common:4.2.15.Final", + "io.netty:netty-transport:4.2.15.Final", "io.opencensus:opencensus-api:0.31.0", "io.opencensus:opencensus-contrib-grpc-metrics:0.31.0", "io.perfmark:perfmark-api:0.27.0", From 09586d2da82aeba703746677d6dbf6ba2b6be75b Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Thu, 11 Jun 2026 09:32:20 -0700 Subject: [PATCH 2/3] Cleanup stale comments/directives --- gradle/libs.versions.toml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 91f71a40733..e88c4f3da25 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -102,18 +102,13 @@ lincheck = "org.jetbrains.lincheck:lincheck:3.4" mockito-android = "org.mockito:mockito-android:4.4.0" # checkForUpdates: mockito-core:4.4.+ mockito-core = "org.mockito:mockito-core:4.4.0" -# Need to decide when we require users to absorb the breaking changes in 4.2 -# checkForUpdates: netty-codec-http2:4.1.+ netty-codec-http2 = "io.netty:netty-codec-http2:4.2.15.Final" -# checkForUpdates: netty-handler-proxy:4.1.+ netty-handler-proxy = "io.netty:netty-handler-proxy:4.2.15.Final" # Keep the following references of tcnative version in sync whenever it's updated: # SECURITY.md netty-tcnative = "io.netty:netty-tcnative-boringssl-static:2.0.75.Final" netty-tcnative-classes = "io.netty:netty-tcnative-classes:2.0.75.Final" -# checkForUpdates: netty-transport-epoll:4.1.+ netty-transport-epoll = "io.netty:netty-transport-native-epoll:4.2.15.Final" -# checkForUpdates: netty-unix-common:4.1.+ netty-unix-common = "io.netty:netty-transport-native-unix-common:4.2.15.Final" okhttp = "com.squareup.okhttp:okhttp:2.7.5" # okio 3.5+ uses Kotlin 1.9+ which requires Android Gradle Plugin 9+ From 54a833b7f4cd97bff3dbabb266201947a6592af1 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Thu, 11 Jun 2026 09:32:33 -0700 Subject: [PATCH 3/3] netty-codec is now netty-codec-base for Bazel For Gradle we pull this in transitively. --- MODULE.bazel | 2 +- alts/BUILD.bazel | 2 +- netty/BUILD.bazel | 2 +- repositories.bzl | 2 +- xds/BUILD.bazel | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index f0d7a48fac1..fe173ba0498 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -26,10 +26,10 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [ "com.squareup.okhttp:okhttp:2.7.5", "com.squareup.okio:okio:2.10.0", # 3.0+ needs swapping to -jvm; need work to avoid flag-day "io.netty:netty-buffer:4.2.15.Final", + "io.netty:netty-codec-base:4.2.15.Final", "io.netty:netty-codec-http2:4.2.15.Final", "io.netty:netty-codec-http:4.2.15.Final", "io.netty:netty-codec-socks:4.2.15.Final", - "io.netty:netty-codec:4.2.15.Final", "io.netty:netty-common:4.2.15.Final", "io.netty:netty-handler-proxy:4.2.15.Final", "io.netty:netty-handler:4.2.15.Final", diff --git a/alts/BUILD.bazel b/alts/BUILD.bazel index f29df303fbe..f02aa511ff5 100644 --- a/alts/BUILD.bazel +++ b/alts/BUILD.bazel @@ -22,7 +22,7 @@ java_library( artifact("com.google.errorprone:error_prone_annotations"), artifact("com.google.guava:guava"), artifact("io.netty:netty-buffer"), - artifact("io.netty:netty-codec"), + artifact("io.netty:netty-codec-base"), artifact("io.netty:netty-common"), artifact("io.netty:netty-handler"), artifact("io.netty:netty-transport"), diff --git a/netty/BUILD.bazel b/netty/BUILD.bazel index 8253d1f5bff..1d7c44e24f5 100644 --- a/netty/BUILD.bazel +++ b/netty/BUILD.bazel @@ -17,7 +17,7 @@ java_library( artifact("com.google.errorprone:error_prone_annotations"), artifact("com.google.guava:guava"), artifact("io.netty:netty-buffer"), - artifact("io.netty:netty-codec"), + artifact("io.netty:netty-codec-base"), artifact("io.netty:netty-codec-http"), artifact("io.netty:netty-codec-http2"), artifact("io.netty:netty-codec-socks"), diff --git a/repositories.bzl b/repositories.bzl index 5dd1a3dd3fc..a679a7749de 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -31,10 +31,10 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [ "com.squareup.okhttp:okhttp:2.7.5", "com.squareup.okio:okio:2.10.0", # 3.0+ needs swapping to -jvm; need work to avoid flag-day "io.netty:netty-buffer:4.2.15.Final", + "io.netty:netty-codec-base:4.2.15.Final", "io.netty:netty-codec-http2:4.2.15.Final", "io.netty:netty-codec-http:4.2.15.Final", "io.netty:netty-codec-socks:4.2.15.Final", - "io.netty:netty-codec:4.2.15.Final", "io.netty:netty-common:4.2.15.Final", "io.netty:netty-handler-proxy:4.2.15.Final", "io.netty:netty-handler:4.2.15.Final", diff --git a/xds/BUILD.bazel b/xds/BUILD.bazel index e36bd37b228..47831c5139c 100644 --- a/xds/BUILD.bazel +++ b/xds/BUILD.bazel @@ -45,7 +45,7 @@ java_library( artifact("dev.cel:protobuf"), artifact("dev.cel:common"), artifact("io.netty:netty-buffer"), - artifact("io.netty:netty-codec"), + artifact("io.netty:netty-codec-base"), artifact("io.netty:netty-common"), artifact("io.netty:netty-handler"), artifact("io.netty:netty-transport"),