Skip to content

Commit 9e1a372

Browse files
committed
Bump Netty to 4.2.0.RC3
1 parent 2a3804d commit 9e1a372

11 files changed

+27
-28
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<spotless.check.skip>true</spotless.check.skip>
5151
<slf4j.version>1.7.36</slf4j.version>
5252
<logback.version>1.2.13</logback.version>
53-
<netty.version>4.1.119.Final</netty.version>
53+
<netty.version>4.2.0.RC3</netty.version>
5454
<proton-j.version>0.34.1</proton-j.version>
5555
<metrics.version>4.2.30</metrics.version>
5656
<micrometer.version>1.14.5</micrometer.version>

src/main/java/com/rabbitmq/stream/impl/Client.java

+2-12
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,7 @@
5959
import io.netty.buffer.ByteBuf;
6060
import io.netty.buffer.ByteBufAllocator;
6161
import io.netty.buffer.ByteBufOutputStream;
62-
import io.netty.channel.Channel;
63-
import io.netty.channel.ChannelFuture;
64-
import io.netty.channel.ChannelHandlerContext;
65-
import io.netty.channel.ChannelInboundHandlerAdapter;
66-
import io.netty.channel.ChannelInitializer;
67-
import io.netty.channel.ChannelOption;
68-
import io.netty.channel.ChannelOutboundHandlerAdapter;
69-
import io.netty.channel.ChannelPromise;
70-
import io.netty.channel.ConnectTimeoutException;
71-
import io.netty.channel.EventLoopGroup;
72-
import io.netty.channel.nio.NioEventLoopGroup;
62+
import io.netty.channel.*;
7363
import io.netty.channel.socket.SocketChannel;
7464
import io.netty.channel.socket.nio.NioSocketChannel;
7565
import io.netty.handler.codec.DecoderException;
@@ -248,7 +238,7 @@ public Client(ClientParameters parameters) {
248238
if (b.config().group() == null) {
249239
EventLoopGroup eventLoopGroup;
250240
if (parameters.eventLoopGroup == null) {
251-
this.eventLoopGroup = new NioEventLoopGroup();
241+
this.eventLoopGroup = Utils.eventLoopGroup();
252242
eventLoopGroup = this.eventLoopGroup;
253243
} else {
254244
this.eventLoopGroup = null;

src/main/java/com/rabbitmq/stream/impl/StreamEnvironment.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
3939
import io.netty.buffer.ByteBufAllocator;
4040
import io.netty.channel.EventLoopGroup;
41-
import io.netty.channel.nio.NioEventLoopGroup;
4241
import io.netty.handler.ssl.SslContext;
4342
import io.netty.handler.ssl.SslContextBuilder;
4443
import java.io.IOException;
@@ -212,7 +211,7 @@ class StreamEnvironment implements Environment {
212211
this.addresses.size(), 1, "rabbitmq-stream-locator-connection-");
213212

214213
if (clientParametersPrototype.eventLoopGroup == null) {
215-
this.eventLoopGroup = new NioEventLoopGroup();
214+
this.eventLoopGroup = Utils.eventLoopGroup();
216215
this.clientParametersPrototype =
217216
clientParametersPrototype.duplicate().eventLoopGroup(this.eventLoopGroup);
218217
} else {

src/main/java/com/rabbitmq/stream/impl/Utils.java

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
import com.rabbitmq.stream.*;
2121
import com.rabbitmq.stream.impl.Client.ClientParameters;
2222
import io.netty.channel.ConnectTimeoutException;
23+
import io.netty.channel.EventLoopGroup;
24+
import io.netty.channel.MultiThreadIoEventLoopGroup;
25+
import io.netty.channel.nio.NioIoHandler;
2326
import java.net.UnknownHostException;
2427
import java.security.cert.X509Certificate;
2528
import java.time.Duration;
@@ -406,6 +409,10 @@ static Function<ClientConnectionType, String> defaultConnectionNamingStrategy(St
406409
prefixes.get(clientConnectionType) + sequences.get(clientConnectionType).getAndIncrement();
407410
}
408411

412+
static EventLoopGroup eventLoopGroup() {
413+
return new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
414+
}
415+
409416
/*
410417
class to help testing SAC on super streams
411418
*/

src/test/java/com/rabbitmq/stream/DefaultEnvironmentTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
import com.rabbitmq.stream.impl.Client;
2121
import io.netty.channel.EventLoopGroup;
22-
import io.netty.channel.nio.NioEventLoopGroup;
22+
import io.netty.channel.MultiThreadIoEventLoopGroup;
23+
import io.netty.channel.nio.NioIoHandler;
2324
import java.util.UUID;
2425
import org.junit.jupiter.api.AfterAll;
2526
import org.junit.jupiter.api.BeforeAll;
@@ -31,7 +32,7 @@ public class DefaultEnvironmentTest {
3132

3233
@BeforeAll
3334
static void initAll() {
34-
eventLoopGroup = new NioEventLoopGroup();
35+
eventLoopGroup = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
3536
}
3637

3738
@AfterAll

src/test/java/com/rabbitmq/stream/docs/EnvironmentUsage.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import com.rabbitmq.stream.observation.micrometer.MicrometerObservationCollectorBuilder;
2020
import io.micrometer.observation.ObservationRegistry;
2121
import io.netty.channel.EventLoopGroup;
22+
import io.netty.channel.MultiThreadIoEventLoopGroup;
2223
import io.netty.channel.epoll.EpollEventLoopGroup;
24+
import io.netty.channel.epoll.EpollIoHandler;
2325
import io.netty.channel.epoll.EpollSocketChannel;
2426
import io.netty.handler.ssl.SslContext;
2527
import io.netty.handler.ssl.SslContextBuilder;
@@ -140,7 +142,9 @@ void deleteStream() {
140142

141143
void nativeEpoll() {
142144
// tag::native-epoll[]
143-
EventLoopGroup epollEventLoopGroup = new EpollEventLoopGroup(); // <1>
145+
EventLoopGroup epollEventLoopGroup = new MultiThreadIoEventLoopGroup( // <1>
146+
EpollIoHandler.newFactory() // <1>
147+
); // <1>
144148
Environment environment = Environment.builder()
145149
.netty() // <2>
146150
.eventLoopGroup(epollEventLoopGroup) // <3>

src/test/java/com/rabbitmq/stream/impl/AlarmsTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import com.rabbitmq.stream.Producer;
3333
import com.rabbitmq.stream.StreamException;
3434
import io.netty.channel.EventLoopGroup;
35-
import io.netty.channel.nio.NioEventLoopGroup;
3635
import java.time.Duration;
3736
import java.util.concurrent.CountDownLatch;
3837
import java.util.concurrent.atomic.AtomicReference;
@@ -56,7 +55,7 @@ public class AlarmsTest {
5655

5756
@BeforeAll
5857
static void initAll() {
59-
eventLoopGroup = new NioEventLoopGroup();
58+
eventLoopGroup = Utils.eventLoopGroup();
6059
}
6160

6261
@AfterAll

src/test/java/com/rabbitmq/stream/impl/MqttInteroperabilityTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import com.rabbitmq.stream.OffsetSpecification;
2828
import com.rabbitmq.stream.amqp.UnsignedByte;
2929
import io.netty.channel.EventLoopGroup;
30-
import io.netty.channel.nio.NioEventLoopGroup;
3130
import java.nio.charset.StandardCharsets;
3231
import java.util.UUID;
3332
import java.util.concurrent.CountDownLatch;
@@ -57,7 +56,7 @@ public class MqttInteroperabilityTest {
5756

5857
@BeforeAll
5958
static void initAll() {
60-
eventLoopGroup = new NioEventLoopGroup();
59+
eventLoopGroup = Utils.eventLoopGroup();
6160
}
6261

6362
@AfterAll

src/test/java/com/rabbitmq/stream/impl/StompInteroperabilityTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import com.rabbitmq.stream.*;
2424
import io.netty.channel.EventLoopGroup;
25-
import io.netty.channel.nio.NioEventLoopGroup;
2625
import java.io.BufferedReader;
2726
import java.io.IOException;
2827
import java.io.InputStreamReader;
@@ -66,7 +65,7 @@ public class StompInteroperabilityTest {
6665

6766
@BeforeAll
6867
static void initAll() {
69-
eventLoopGroup = new NioEventLoopGroup();
68+
eventLoopGroup = Utils.eventLoopGroup();
7069
}
7170

7271
@AfterAll

src/test/java/com/rabbitmq/stream/impl/StreamEnvironmentTest.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
import com.rabbitmq.stream.impl.TestUtils.DisabledIfTlsNotEnabled;
5252
import io.netty.channel.Channel;
5353
import io.netty.channel.EventLoopGroup;
54-
import io.netty.channel.epoll.EpollEventLoopGroup;
54+
import io.netty.channel.MultiThreadIoEventLoopGroup;
55+
import io.netty.channel.epoll.EpollIoHandler;
5556
import io.netty.channel.epoll.EpollSocketChannel;
5657
import io.netty.handler.ssl.SslHandler;
5758
import java.net.ConnectException;
@@ -723,7 +724,8 @@ void nettyInitializersAreCalled() {
723724
@EnabledIfSystemProperty(named = "os.arch", matches = "amd64")
724725
void nativeEpollWorksOnLinux() {
725726
int messageCount = 10_000;
726-
EventLoopGroup epollEventLoopGroup = new EpollEventLoopGroup();
727+
EventLoopGroup epollEventLoopGroup =
728+
new MultiThreadIoEventLoopGroup(EpollIoHandler.newFactory());
727729
try {
728730
Set<Channel> channels = ConcurrentHashMap.newKeySet();
729731
try (Environment env =

src/test/java/com/rabbitmq/stream/impl/TestUtils.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import com.rabbitmq.stream.impl.Client.Response;
4343
import com.rabbitmq.stream.impl.Client.StreamMetadata;
4444
import io.netty.channel.EventLoopGroup;
45-
import io.netty.channel.nio.NioEventLoopGroup;
4645
import io.vavr.Tuple2;
4746
import java.io.IOException;
4847
import java.lang.annotation.Documented;
@@ -627,7 +626,7 @@ static EventLoopGroup eventLoopGroup(ExtensionContext context) {
627626

628627
@Override
629628
public void beforeAll(ExtensionContext context) {
630-
store(context).put("nettyEventLoopGroup", new NioEventLoopGroup());
629+
store(context).put("nettyEventLoopGroup", Utils.eventLoopGroup());
631630
}
632631

633632
@Override

0 commit comments

Comments
 (0)