This is an automated email from the ASF dual-hosted git repository.
heliang666s pushed a commit to branch 3.3
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.3 by this push:
new 7883aab069 fix:JDK 25 Netty EventLoopGroup creation and ignore unsafe
warning (#15764)
7883aab069 is described below
commit 7883aab069fffbffecb946f30f5c268ae379fb5b
Author: redoom <[email protected]>
AuthorDate: Tue Nov 11 14:07:40 2025 +0800
fix:JDK 25 Netty EventLoopGroup creation and ignore unsafe warning (#15764)
---
.github/workflows/build-and-test-pr.yml | 3 +++
.github/workflows/build-and-test-scheduled-3.3.yml | 18 ++++++++++++++++++
.github/workflows/release-test.yml | 18 ++++++++++++++++++
.../transport/netty4/NettyEventLoopFactory.java | 8 +++++---
4 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/build-and-test-pr.yml
b/.github/workflows/build-and-test-pr.yml
index d612b7ebd6..529514886e 100644
--- a/.github/workflows/build-and-test-pr.yml
+++ b/.github/workflows/build-and-test-pr.yml
@@ -218,6 +218,9 @@ jobs:
CURRENT_ROLE: ${{ matrix.case-role }}
ZOOKEEPER_VERSION: 3.7.2
steps:
+ - name: "Set MAVEN_OPTS for JDK 24+"
+ if: ${{ matrix.java >= 24 }}
+ run: echo "MAVEN_OPTS=--sun-misc-unsafe-memory-access=allow" >>
$GITHUB_ENV
- name: "Checkout code"
uses: actions/checkout@v4
with:
diff --git a/.github/workflows/build-and-test-scheduled-3.3.yml
b/.github/workflows/build-and-test-scheduled-3.3.yml
index b7d0d0a3b8..02c2cf201d 100644
--- a/.github/workflows/build-and-test-scheduled-3.3.yml
+++ b/.github/workflows/build-and-test-scheduled-3.3.yml
@@ -136,6 +136,12 @@ jobs:
env:
DISABLE_FILE_SYSTEM_TEST: true
steps:
+ - name: "Set MAVEN_OPTS for JDK 24+ on Linux"
+ if: ${{ matrix.jdk >= 24 && startsWith(matrix.os, 'ubuntu') }}
+ run: echo "MAVEN_OPTS=--sun-misc-unsafe-memory-access=allow" >>
$GITHUB_ENV
+ - name: "Set MAVEN_OPTS for JDK 24+ on Windows"
+ if: ${{ matrix.jdk >= 24 && startsWith(matrix.os, 'windows') }}
+ run: echo "MAVEN_OPTS=--sun-misc-unsafe-memory-access=allow" >>
$env:GITHUB_ENV
- uses: actions/checkout@v4
with:
ref: "3.3"
@@ -182,6 +188,12 @@ jobs:
DUBBO_DEFAULT_SERIALIZATION: fastjson2
MAVEN_SUREFIRE_ADD_OPENS: true
steps:
+ - name: "Set MAVEN_OPTS for JDK 24+ on Linux"
+ if: ${{ matrix.jdk >= 24 && startsWith(matrix.os, 'ubuntu') }}
+ run: echo "MAVEN_OPTS=--sun-misc-unsafe-memory-access=allow" >>
$GITHUB_ENV
+ - name: "Set MAVEN_OPTS for JDK 24+ on Windows"
+ if: ${{ matrix.jdk >= 24 && startsWith(matrix.os, 'windows') }}
+ run: echo "MAVEN_OPTS=--sun-misc-unsafe-memory-access=allow" >>
$env:GITHUB_ENV
- uses: actions/checkout@v4
- name: "Set up JDK ${{ matrix.jdk }}"
uses: actions/setup-java@v4
@@ -252,6 +264,9 @@ jobs:
jdk: [ 8, 11, 17, 21, 25 ]
job_id: [1, 2, 3, 4, 5]
steps:
+ - name: "Set MAVEN_OPTS for JDK 24+"
+ if: ${{ matrix.jdk >= 24 }}
+ run: echo "MAVEN_OPTS=--sun-misc-unsafe-memory-access=allow" >>
$GITHUB_ENV
- uses: actions/checkout@v4
with:
repository: 'apache/dubbo-samples'
@@ -358,6 +373,9 @@ jobs:
jdk: [ 8, 11, 17, 21, 25 ]
job_id: [1, 2, 3, 4, 5]
steps:
+ - name: "Set MAVEN_OPTS for JDK 24+"
+ if: ${{ matrix.jdk >= 24 }}
+ run: echo "MAVEN_OPTS=--sun-misc-unsafe-memory-access=allow" >>
$GITHUB_ENV
- uses: actions/checkout@v4
with:
repository: 'apache/dubbo-integration-cases'
diff --git a/.github/workflows/release-test.yml
b/.github/workflows/release-test.yml
index 1ab14e9672..bb3697c99c 100644
--- a/.github/workflows/release-test.yml
+++ b/.github/workflows/release-test.yml
@@ -133,6 +133,12 @@ jobs:
DISABLE_FILE_SYSTEM_TEST: true
steps:
- uses: actions/checkout@v4
+ - name: "Set MAVEN_OPTS for JDK 24+ on Linux"
+ if: ${{ matrix.jdk >= 24 && startsWith(matrix.os, 'ubuntu') }}
+ run: echo "MAVEN_OPTS=--sun-misc-unsafe-memory-access=allow" >>
$GITHUB_ENV
+ - name: "Set MAVEN_OPTS for JDK 24+ on Windows"
+ if: ${{ matrix.jdk >= 24 && startsWith(matrix.os, 'windows') }}
+ run: echo "MAVEN_OPTS=--sun-misc-unsafe-memory-access=allow" >>
$env:GITHUB_ENV
- name: "Set up JDK ${{ matrix.jdk }}"
uses: actions/setup-java@v4
with:
@@ -178,6 +184,12 @@ jobs:
MAVEN_SUREFIRE_ADD_OPENS: true
steps:
- uses: actions/checkout@v4
+ - name: "Set MAVEN_OPTS for JDK 24+ on Linux"
+ if: ${{ matrix.jdk >= 24 && startsWith(matrix.os, 'ubuntu') }}
+ run: echo "MAVEN_OPTS=--sun-misc-unsafe-memory-access=allow" >>
$GITHUB_ENV
+ - name: "Set MAVEN_OPTS for JDK 24+ on Windows"
+ if: ${{ matrix.jdk >= 24 && startsWith(matrix.os, 'windows') }}
+ run: echo "MAVEN_OPTS=--sun-misc-unsafe-memory-access=allow" >>
$env:GITHUB_ENV
- name: "Set up JDK ${{ matrix.jdk }}"
uses: actions/setup-java@v4
with:
@@ -251,6 +263,9 @@ jobs:
with:
repository: 'apache/dubbo-samples'
ref: master
+ - name: "Set MAVEN_OPTS for JDK 24+"
+ if: ${{ matrix.jdk >= 24 }}
+ run: echo "MAVEN_OPTS=--sun-misc-unsafe-memory-access=allow" >>
$GITHUB_ENV
- name: "Cache local Maven repository"
uses: actions/cache@v3
with:
@@ -351,6 +366,9 @@ jobs:
with:
repository: 'apache/dubbo-integration-cases'
ref: main
+ - name: "Set MAVEN_OPTS for JDK 24+"
+ if: ${{ matrix.jdk >= 24 }}
+ run: echo "MAVEN_OPTS=--sun-misc-unsafe-memory-access=allow" >>
$GITHUB_ENV
- name: "Cache local Maven repository"
uses: actions/cache@v3
with:
diff --git
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyEventLoopFactory.java
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyEventLoopFactory.java
index 0ecae22ee2..b9db82af5b 100644
---
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyEventLoopFactory.java
+++
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyEventLoopFactory.java
@@ -49,9 +49,11 @@ public class NettyEventLoopFactory {
public static EventLoopGroup eventLoopGroup(int threads, String
threadFactoryName) {
ThreadFactory threadFactory = new
DefaultThreadFactory(threadFactoryName, true);
- return shouldEpoll()
- ? new EpollEventLoopGroup(threads, threadFactory)
- : new NioEventLoopGroup(threads, threadFactory);
+ if (shouldEpoll()) {
+ return new EpollEventLoopGroup(threads, threadFactory);
+ } else {
+ return new NioEventLoopGroup(threads, threadFactory);
+ }
}
public static Class<? extends SocketChannel> socketChannelClass() {