Skip to content

Commit 1acd290

Browse files
authored
Add java 18 to our CI (netty#12402)
Motivation: We should ensure the testsuites also pass on java 18 Modifications: - Add java 18 ci setup - Add profile for java 18 - Rename compose file to reflect its actually using centos7 - Disable blockhound on Java 18 and above, because their byte-buddy dependency does not support it. Result: Tests run on java 18 as well
1 parent 7de44fb commit 1acd290

File tree

8 files changed

+114
-30
lines changed

8 files changed

+114
-30
lines changed

.github/workflows/ci-pr-reports.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
- setup: linux-x86_64-java11
3636
- setup: linux-x86_64-java11-boringssl
3737
- setup: linux-x86_64-java17
38+
- setup: linux-x86_64-java18
3839
- setup: windows-x86_64-java11-boringssl
3940
continue-on-error: ${{ matrix.ignore-if-missing }}
4041
steps:

.github/workflows/ci-pr.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,11 @@ jobs:
148148
docker-compose-build: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.graalvm111.yaml build"
149149
docker-compose-run: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.graalvm111.yaml run build-leak"
150150
- setup: linux-x86_64-java17
151-
docker-compose-build: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.117.yaml build"
152-
docker-compose-run: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.117.yaml run build-leak"
151+
docker-compose-build: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-7.117.yaml build"
152+
docker-compose-run: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-7.117.yaml run build-leak"
153+
- setup: linux-x86_64-java18
154+
docker-compose-build: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-7.118.yaml build"
155+
docker-compose-run: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-7.118.yaml run build-leak"
153156
- setup: linux-x86_64-java11-boringssl
154157
docker-compose-build: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.111.yaml build"
155158
docker-compose-run: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.111.yaml run build-leak-boringssl-static"

common/src/test/java/io/netty/util/concurrent/DefaultThreadFactoryTest.java

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package io.netty.util.concurrent;
1818

19+
import org.junit.jupiter.api.Assumptions;
1920
import org.junit.jupiter.api.Test;
2021
import org.junit.jupiter.api.Timeout;
2122

@@ -31,31 +32,38 @@
3132
import static org.junit.jupiter.api.Assertions.assertTrue;
3233

3334
public class DefaultThreadFactoryTest {
35+
3436
@Test
3537
@Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
3638
public void testDescendantThreadGroups() throws InterruptedException {
3739
final SecurityManager current = System.getSecurityManager();
3840

41+
boolean securityManagerSet = false;
3942
try {
40-
// install security manager that only allows parent thread groups to mess with descendant thread groups
41-
System.setSecurityManager(new SecurityManager() {
42-
@Override
43-
public void checkAccess(ThreadGroup g) {
44-
final ThreadGroup source = Thread.currentThread().getThreadGroup();
45-
46-
if (source != null) {
47-
if (!source.parentOf(g)) {
48-
throw new SecurityException("source group is not an ancestor of the target group");
43+
try {
44+
// install security manager that only allows parent thread groups to mess with descendant thread groups
45+
System.setSecurityManager(new SecurityManager() {
46+
@Override
47+
public void checkAccess(ThreadGroup g) {
48+
final ThreadGroup source = Thread.currentThread().getThreadGroup();
49+
50+
if (source != null) {
51+
if (!source.parentOf(g)) {
52+
throw new SecurityException("source group is not an ancestor of the target group");
53+
}
54+
super.checkAccess(g);
4955
}
50-
super.checkAccess(g);
5156
}
52-
}
5357

54-
// so we can restore the security manager at the end of the test
55-
@Override
56-
public void checkPermission(Permission perm) {
57-
}
58-
});
58+
// so we can restore the security manager at the end of the test
59+
@Override
60+
public void checkPermission(Permission perm) {
61+
}
62+
});
63+
} catch (UnsupportedOperationException e) {
64+
Assumptions.assumeFalse(true, "Setting SecurityManager not supported");
65+
}
66+
securityManagerSet = true;
5967

6068
// holder for the thread factory, plays the role of a global singleton
6169
final AtomicReference<DefaultThreadFactory> factory = new AtomicReference<DefaultThreadFactory>();
@@ -114,7 +122,9 @@ public void run() {
114122

115123
assertEquals(2, counter.get());
116124
} finally {
117-
System.setSecurityManager(current);
125+
if (securityManagerSet) {
126+
System.setSecurityManager(current);
127+
}
118128
}
119129
}
120130

@@ -141,19 +151,26 @@ public DefaultThreadFactory call() throws Exception {
141151
public void testDefaultThreadFactoryInheritsThreadGroupFromSecurityManager() throws InterruptedException {
142152
final SecurityManager current = System.getSecurityManager();
143153

154+
boolean securityManagerSet = false;
144155
try {
145156
final ThreadGroup sticky = new ThreadGroup("sticky");
146-
System.setSecurityManager(new SecurityManager() {
147-
@Override
148-
public ThreadGroup getThreadGroup() {
149-
return sticky;
150-
}
157+
try {
158+
System.setSecurityManager(new SecurityManager() {
159+
@Override
160+
public ThreadGroup getThreadGroup() {
161+
return sticky;
162+
}
163+
164+
// so we can restore the security manager at the end of the test
165+
@Override
166+
public void checkPermission(Permission perm) {
167+
}
168+
});
169+
} catch (UnsupportedOperationException e) {
170+
Assumptions.assumeFalse(true, "Setting SecurityManager not supported");
171+
}
172+
securityManagerSet = true;
151173

152-
// so we can restore the security manager at the end of the test
153-
@Override
154-
public void checkPermission(Permission perm) {
155-
}
156-
});
157174
runStickyThreadGroupTest(
158175
new Callable<DefaultThreadFactory>() {
159176
@Override
@@ -163,7 +180,9 @@ public DefaultThreadFactory call() throws Exception {
163180
},
164181
sticky);
165182
} finally {
166-
System.setSecurityManager(current);
183+
if (securityManagerSet) {
184+
System.setSecurityManager(current);
185+
}
167186
}
168187
}
169188

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: "3"
2+
3+
services:
4+
5+
runtime-setup:
6+
image: netty:centos-7-1.17
7+
build:
8+
args:
9+
java_version : "18.0.1-zulu"
10+
11+
build:
12+
image: netty:centos-7-1.17
13+
14+
build-leak:
15+
image: netty:centos-7-1.17
16+
17+
build-boringssl-static:
18+
image: netty:centos-7-1.17
19+
20+
build-leak-boringssl-static:
21+
image: netty:centos-7-1.17
22+
23+
shell:
24+
image: netty:centos-7-1.17

pom.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,28 @@
181181
<testJvm />
182182
</properties>
183183
</profile>
184+
<profile>
185+
<id>java18</id>
186+
<activation>
187+
<jdk>18</jdk>
188+
</activation>
189+
<properties>
190+
<!-- Not use alpn agent as Java11+ supports alpn out of the box -->
191+
<argLine.alpnAgent />
192+
<argLine.java9.extras />
193+
<!-- Export some stuff which is used during our tests -->
194+
<argLine.java9>--illegal-access=deny ${argLine.java9.extras}</argLine.java9>
195+
<forbiddenapis.skip>true</forbiddenapis.skip>
196+
<!-- 1.4.x does not work in Java10+ -->
197+
<jboss.marshalling.version>2.0.5.Final</jboss.marshalling.version>
198+
<!-- This is the minimum supported by Java12+ -->
199+
<maven.compiler.source>1.7</maven.compiler.source>
200+
<maven.compiler.target>1.7</maven.compiler.target>
201+
<!-- pax-exam does not work on latest Java12 EA 22 build -->
202+
<skipOsgiTestsuite>true</skipOsgiTestsuite>
203+
<revapi.skip>true</revapi.skip>
204+
</properties>
205+
</profile>
184206
<profile>
185207
<id>java17</id>
186208
<activation>

transport-blockhound-tests/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@
7777
<argLine.common>-XX:+AllowRedefinitionToAddDeleteMethods</argLine.common>
7878
</properties>
7979
</profile>
80+
<profile>
81+
<id>java18</id>
82+
<activation>
83+
<jdk>18</jdk>
84+
</activation>
85+
<properties>
86+
<argLine.common>-XX:+AllowRedefinitionToAddDeleteMethods</argLine.common>
87+
</properties>
88+
</profile>
8089
</profiles>
8190

8291
<properties>

transport-blockhound-tests/src/test/java/io/netty/util/internal/NettyBlockHoundIntegrationTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.junit.jupiter.api.BeforeAll;
5353
import org.junit.jupiter.api.Test;
5454
import org.junit.jupiter.api.Timeout;
55+
import org.junit.jupiter.api.condition.DisabledIf;
5556
import reactor.blockhound.BlockHound;
5657
import reactor.blockhound.BlockingOperationError;
5758
import reactor.blockhound.integration.BlockHoundIntegration;
@@ -82,8 +83,13 @@
8283
import static org.junit.jupiter.api.Assertions.fail;
8384
import static org.junit.jupiter.api.Assumptions.assumeTrue;
8485

86+
@DisabledIf("isDisabledIfJavaVersion18OrAbove")
8587
public class NettyBlockHoundIntegrationTest {
8688

89+
private static boolean isDisabledIfJavaVersion18OrAbove() {
90+
return PlatformDependent.javaVersion() >= 18;
91+
}
92+
8793
@BeforeAll
8894
public static void setUpClass() {
8995
BlockHound.install();

0 commit comments

Comments
 (0)