Skip to content

Commit a6c0e14

Browse files
committed
ARTEMIS-5734 upgrade to Netty 4.2.7.Final
1 parent 1c1924c commit a6c0e14

27 files changed

Lines changed: 129 additions & 101 deletions

File tree

artemis-cli/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,13 @@
239239
</execution>
240240
</executions>
241241
</plugin>
242+
<plugin>
243+
<groupId>org.apache.maven.plugins</groupId>
244+
<artifactId>maven-surefire-plugin</artifactId>
245+
<configuration>
246+
<argLine>${activemq-surefire-argline}</argLine>
247+
</configuration>
248+
</plugin>
242249
</plugins>
243250
</build>
244251

artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ if [ -f "$ARTEMIS_OOME_DUMP" ] ; then
119119
mv $ARTEMIS_OOME_DUMP $ARTEMIS_OOME_DUMP.bkp
120120
fi
121121

122+
# Netty needs access to unsafe, but this is turned off in Java 25 by default
123+
$JAVACMD --sun-misc-unsafe-memory-access=allow --version > /dev/null 2>&1 && ALLOW_UNSAFE="--sun-misc-unsafe-memory-access=allow"
124+
122125
exec "$JAVACMD" \
123126
$LOGGING_ARGS \
124127
$JAVA_ARGS \
@@ -132,6 +135,7 @@ exec "$JAVACMD" \
132135
-Djava.io.tmpdir="$ARTEMIS_INSTANCE/tmp" \
133136
-Ddata.dir="$ARTEMIS_DATA_DIR" \
134137
-Dartemis.instance.etc="$ARTEMIS_INSTANCE_ETC" \
138+
$ALLOW_UNSAFE \
135139
$DEBUG_ARGS \
136140
$JAVA_ARGS_APPEND \
137141
org.apache.activemq.artemis.boot.Artemis "$@"

artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis-utility.profile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if [ -z "$LOGGING_ARGS" ]; then
2424
fi
2525

2626
if [ -z "$JAVA_ARGS" ]; then
27-
JAVA_ARGS="-Dlog4j2.disableJmx=true --add-opens java.base/jdk.internal.misc=ALL-UNNAMED ${java-utility-opts}"
27+
JAVA_ARGS="-Dlog4j2.disableJmx=true --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --enable-native-access=ALL-UNNAMED ${java-utility-opts}"
2828
fi
2929

3030
# Uncomment to enable remote debugging

artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ HAWTIO_ROLES='${role}'
3030

3131
# Java Opts
3232
if [ -z "$JAVA_ARGS" ]; then
33-
JAVA_ARGS="-XX:AutoBoxCacheMax=20000 -XX:+PrintClassHistogram -XX:+UseG1GC -XX:+UseStringDeduplication -Xms512M -Xmx${java-memory} -Dhawtio.disableProxy=true -Dhawtio.realm=activemq -Dhawtio.offline=true -Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal -Dhawtio.http.strictTransportSecurity=max-age=31536000;includeSubDomains;preload -Djolokia.policyLocation=classpath:jolokia-access.xml -Dlog4j2.disableJmx=true --add-opens java.base/jdk.internal.misc=ALL-UNNAMED ${java-opts}"
33+
JAVA_ARGS="-XX:AutoBoxCacheMax=20000 -XX:+PrintClassHistogram -XX:+UseG1GC -XX:+UseStringDeduplication -Xms512M -Xmx${java-memory} -Dhawtio.disableProxy=true -Dhawtio.realm=activemq -Dhawtio.offline=true -Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal -Dhawtio.http.strictTransportSecurity=max-age=31536000;includeSubDomains;preload -Djolokia.policyLocation=classpath:jolokia-access.xml -Dlog4j2.disableJmx=true --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --enable-native-access=ALL-UNNAMED ${java-opts}"
3434
fi
3535

3636
# Uncomment to enable logging for Safepoint JVM pauses

artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ByteUtilTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ public void shouldZeroesDirectByteBuffer() {
223223

224224
@Test
225225
public void shouldZeroesLimitedDirectByteBuffer() {
226+
assumeTrue(PlatformDependent.hasUnsafe());
226227
final byte one = (byte) 1;
227228
final int capacity = 64;
228229
final int bytes = 32;

artemis-core-client-osgi/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<Import-Package>
7171
org.glassfish.json*;resolution:=optional,
7272
de.dentrassi.crypto.pem;resolution:=optional,
73-
io.netty.buffer;io.netty.*;version="[4.1,5)",
73+
io.netty.*;version="[4.2,5)",
7474
*
7575
</Import-Package>
7676
<_exportcontents>org.apache.activemq.artemis.*;-noimport:=true</_exportcontents>

artemis-core-client/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@
109109
<groupId>io.netty</groupId>
110110
<artifactId>netty-handler-proxy</artifactId>
111111
</dependency>
112-
<dependency>
113-
<groupId>io.netty</groupId>
114-
<artifactId>netty-codec</artifactId>
115-
</dependency>
116112
<dependency>
117113
<groupId>io.netty</groupId>
118114
<artifactId>netty-codec-socks</artifactId>

artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
*/
1717
package org.apache.activemq.artemis.core.remoting.impl.netty;
1818

19-
import static org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.NETTY_HTTP_HEADER_PREFIX;
20-
2119
import javax.net.ssl.SNIHostName;
2220
import javax.net.ssl.SSLContext;
2321
import javax.net.ssl.SSLEngine;
2422
import javax.net.ssl.SSLParameters;
2523
import java.io.IOException;
24+
import java.lang.invoke.MethodHandles;
2625
import java.net.ConnectException;
2726
import java.net.InetAddress;
2827
import java.net.InetSocketAddress;
@@ -63,15 +62,16 @@
6362
import io.netty.channel.ChannelPipeline;
6463
import io.netty.channel.ChannelPromise;
6564
import io.netty.channel.EventLoopGroup;
65+
import io.netty.channel.MultiThreadIoEventLoopGroup;
6666
import io.netty.channel.SimpleChannelInboundHandler;
6767
import io.netty.channel.WriteBufferWaterMark;
68-
import io.netty.channel.epoll.EpollEventLoopGroup;
68+
import io.netty.channel.epoll.EpollIoHandler;
6969
import io.netty.channel.epoll.EpollSocketChannel;
7070
import io.netty.channel.group.ChannelGroup;
7171
import io.netty.channel.group.DefaultChannelGroup;
72-
import io.netty.channel.kqueue.KQueueEventLoopGroup;
72+
import io.netty.channel.kqueue.KQueueIoHandler;
7373
import io.netty.channel.kqueue.KQueueSocketChannel;
74-
import io.netty.channel.nio.NioEventLoopGroup;
74+
import io.netty.channel.nio.NioIoHandler;
7575
import io.netty.channel.socket.nio.NioSocketChannel;
7676
import io.netty.handler.codec.base64.Base64;
7777
import io.netty.handler.codec.http.DefaultFullHttpRequest;
@@ -92,11 +92,11 @@
9292
import io.netty.handler.codec.http.LastHttpContent;
9393
import io.netty.handler.codec.http.cookie.ClientCookieDecoder;
9494
import io.netty.handler.codec.http.cookie.Cookie;
95-
import io.netty.handler.ssl.SslContext;
9695
import io.netty.handler.codec.socksx.SocksVersion;
9796
import io.netty.handler.proxy.ProxyHandler;
9897
import io.netty.handler.proxy.Socks4ProxyHandler;
9998
import io.netty.handler.proxy.Socks5ProxyHandler;
99+
import io.netty.handler.ssl.SslContext;
100100
import io.netty.handler.ssl.SslHandler;
101101
import io.netty.resolver.NoopAddressResolverGroup;
102102
import io.netty.util.AttributeKey;
@@ -128,8 +128,8 @@
128128
import org.apache.activemq.artemis.utils.PasswordMaskingUtil;
129129
import org.slf4j.Logger;
130130
import org.slf4j.LoggerFactory;
131-
import java.lang.invoke.MethodHandles;
132131

132+
import static org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.NETTY_HTTP_HEADER_PREFIX;
133133
import static org.apache.activemq.artemis.utils.Base64.encodeBytes;
134134

135135
public class NettyConnector extends AbstractConnector {
@@ -537,29 +537,29 @@ public synchronized void start() {
537537

538538
if (useEpoll && CheckDependencies.isEpollAvailable()) {
539539
if (useGlobalWorkerPool) {
540-
group = SharedEventLoopGroup.getInstance((threadFactory -> new EpollEventLoopGroup(remotingThreads, threadFactory)));
540+
group = SharedEventLoopGroup.getInstance((threadFactory -> new MultiThreadIoEventLoopGroup(remotingThreads, threadFactory, EpollIoHandler.newFactory())));
541541
} else {
542-
group = new EpollEventLoopGroup(remotingThreads);
542+
group = new MultiThreadIoEventLoopGroup(remotingThreads, EpollIoHandler.newFactory());
543543
}
544544
connectorType = EPOLL_CONNECTOR_TYPE;
545545
channelClazz = EpollSocketChannel.class;
546546
logger.debug("Connector {} using native epoll", this);
547547
} else if (useKQueue && CheckDependencies.isKQueueAvailable()) {
548548
if (useGlobalWorkerPool) {
549-
group = SharedEventLoopGroup.getInstance((threadFactory -> new KQueueEventLoopGroup(remotingThreads, threadFactory)));
549+
group = SharedEventLoopGroup.getInstance((threadFactory -> new MultiThreadIoEventLoopGroup(remotingThreads, threadFactory, KQueueIoHandler.newFactory())));
550550
} else {
551-
group = new KQueueEventLoopGroup(remotingThreads);
551+
group = new MultiThreadIoEventLoopGroup(remotingThreads, KQueueIoHandler.newFactory());
552552
}
553553
connectorType = KQUEUE_CONNECTOR_TYPE;
554554
channelClazz = KQueueSocketChannel.class;
555555
logger.debug("Connector {} using native kqueue", this);
556556
} else {
557557
if (useGlobalWorkerPool) {
558558
channelClazz = NioSocketChannel.class;
559-
group = SharedEventLoopGroup.getInstance((threadFactory -> new NioEventLoopGroup(remotingThreads, threadFactory)));
559+
group = SharedEventLoopGroup.getInstance((threadFactory -> new MultiThreadIoEventLoopGroup(remotingThreads, threadFactory, NioIoHandler.newFactory())));
560560
} else {
561561
channelClazz = NioSocketChannel.class;
562-
group = new NioEventLoopGroup(remotingThreads);
562+
group = new MultiThreadIoEventLoopGroup(remotingThreads, NioIoHandler.newFactory());
563563
}
564564
connectorType = NIO_CONNECTOR_TYPE;
565565
channelClazz = NioSocketChannel.class;

artemis-distribution/src/main/resources/bin/artemis

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,15 @@ if $cygwin ; then
9090
CLASSPATH=`cygpath --windows "$CLASSPATH"`
9191
fi
9292

93+
# Netty needs access to unsafe, but this is turned off in Java 25 by default
94+
$JAVACMD --sun-misc-unsafe-memory-access=allow --version > /dev/null 2>&1 && ALLOW_UNSAFE="--sun-misc-unsafe-memory-access=allow"
95+
9396
exec "$JAVACMD" $JAVA_ARGS $ARTEMIS_CLUSTER_PROPS \
9497
-classpath "$CLASSPATH" \
9598
-Dartemis.home="$ARTEMIS_HOME" \
9699
-Djava.library.path="$ARTEMIS_HOME/bin/lib/linux-$(uname -m)" \
100+
--enable-native-access=ALL-UNNAMED \
101+
$ALLOW_UNSAFE \
97102
$DEBUG_ARGS \
98103
$JAVA_ARGS_APPEND \
99104
org.apache.activemq.artemis.boot.Artemis "$@"

artemis-features/src/main/resources/features.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
<bundle>mvn:io.netty/netty-resolver/${netty.version}</bundle>
3434
<bundle>mvn:io.netty/netty-transport/${netty.version}</bundle>
3535
<bundle>mvn:io.netty/netty-buffer/${netty.version}</bundle>
36-
<bundle>mvn:io.netty/netty-codec/${netty.version}</bundle>
36+
<bundle>mvn:io.netty/netty-codec-base/${netty.version}</bundle>
37+
<bundle>mvn:io.netty/netty-codec-compression/${netty.version}</bundle>
3738
<bundle>mvn:io.netty/netty-codec-socks/${netty.version}</bundle>
3839
<bundle>mvn:io.netty/netty-codec-haproxy/${netty.version}</bundle>
3940
<bundle>mvn:io.netty/netty-codec-http/${netty.version}</bundle>

0 commit comments

Comments
 (0)