Skip to content

Commit b25f5a3

Browse files
retaadnapibar
andauthored
[Backport] [2.x] Update bundled JDK to JDK-21.0.1 (#10576) (#11003)
* Update bundled JDK to JDK-21.0.1 (#10576) Signed-off-by: Andriy Redko <andriy.redko@aiven.io> (cherry picked from commit 0d7d1e9) Signed-off-by: Andriy Redko <andriy.redko@aiven.io> * Add condition to check JVM version for illegal-access switch (#5279) This switch is removed in JDK version 17. https://openjdk.org/jeps/403 Signed-off-by: Rabi Panda <adnapibar@gmail.com> * Check for JDK version while setting java.security.manager option (#5205) Signed-off-by: Rabi Panda <adnapibar@gmail.com> * Fix tests and test skaffolding Signed-off-by: Andriy Redko <andriy.redko@aiven.io> --------- Signed-off-by: Andriy Redko <andriy.redko@aiven.io> Signed-off-by: Rabi Panda <adnapibar@gmail.com> Co-authored-by: Rabi Panda <adnapibar@gmail.com>
1 parent 7606cbc commit b25f5a3

File tree

12 files changed

+88
-36
lines changed

12 files changed

+88
-36
lines changed

buildSrc/src/main/java/org/opensearch/gradle/OpenSearchTestBasePlugin.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ public void execute(Task t) {
111111
test.systemProperty("java.locale.providers", "SPI,JRE");
112112
} else {
113113
test.systemProperty("java.locale.providers", "SPI,COMPAT");
114-
test.jvmArgs("--illegal-access=warn");
114+
if (test.getJavaVersion().compareTo(JavaVersion.VERSION_17) < 0) {
115+
test.jvmArgs("--illegal-access=warn");
116+
}
117+
}
118+
if (test.getJavaVersion().compareTo(JavaVersion.VERSION_17) > 0) {
119+
test.jvmArgs("-Djava.security.manager=allow");
115120
}
116121
}
117122
});

buildSrc/src/main/java/org/opensearch/gradle/test/DistroTestPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@
7777
import java.util.stream.Stream;
7878

7979
public class DistroTestPlugin implements Plugin<Project> {
80-
private static final String SYSTEM_JDK_VERSION = "11.0.20+8";
80+
private static final String SYSTEM_JDK_VERSION = "17.0.9+9";
8181
private static final String SYSTEM_JDK_VENDOR = "adoptium";
82-
private static final String GRADLE_JDK_VERSION = "17.0.8+7";
82+
private static final String GRADLE_JDK_VERSION = "17.0.9+9";
8383
private static final String GRADLE_JDK_VENDOR = "adoptium";
8484

8585
// all distributions used by distro tests. this is temporary until tests are per distribution

buildSrc/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ opensearch = 2.12.0
22
lucene = 9.8.0
33

44
bundled_jdk_vendor = adoptium
5-
bundled_jdk = 17.0.8+7
5+
bundled_jdk = 21.0.1+12
66

77
# optional dependencies
88
spatial4j = 0.7

distribution/src/config/jvm.options

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ${error.file}
8181

8282
# JDK 20+ Incubating Vector Module for SIMD optimizations;
8383
# disabling may reduce performance on vector optimized lucene
84-
20:--add-modules=jdk.incubator.vector
84+
20-:--add-modules=jdk.incubator.vector
8585

8686
# HDFS ForkJoinPool.common() support by SecurityManager
8787
-Djava.util.concurrent.ForkJoinPool.common.threadFactory=org.opensearch.secure_sm.SecuredForkJoinWorkerThreadFactory

distribution/tools/launchers/src/main/java/org/opensearch/tools/launchers/SystemJvmOptions.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,21 @@ static List<String> systemJvmOptions() {
7777
// log4j 2
7878
"-Dlog4j.shutdownHookEnabled=false",
7979
"-Dlog4j2.disable.jmx=true",
80-
80+
// security manager
81+
allowSecurityManagerOption(),
8182
javaLocaleProviders()
8283
)
8384
).stream().filter(e -> e.isEmpty() == false).collect(Collectors.toList());
8485
}
8586

87+
private static String allowSecurityManagerOption() {
88+
if (Runtime.version().feature() > 17) {
89+
return "-Djava.security.manager=allow";
90+
} else {
91+
return "";
92+
}
93+
}
94+
8695
private static String maybeShowCodeDetailsInExceptionMessages() {
8796
if (Runtime.version().feature() >= 14) {
8897
return "-XX:+ShowCodeDetailsInExceptionMessages";

libs/core/build.gradle

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,23 @@ tasks.named('forbiddenApisMain').configure {
104104
tasks.named("thirdPartyAudit").configure {
105105
ignoreMissingClasses(
106106
// from log4j
107-
'org.osgi.framework.Bundle',
108-
'org.osgi.framework.BundleActivator',
109-
'org.osgi.framework.BundleContext',
110-
'org.osgi.framework.BundleEvent',
111-
'org.osgi.framework.FrameworkUtil',
112-
'org.osgi.framework.ServiceReference',
113-
'org.osgi.framework.ServiceRegistration',
114-
'org.osgi.framework.SynchronousBundleListener',
115-
'org.osgi.framework.wiring.BundleWire',
116-
'org.osgi.framework.wiring.BundleWiring'
107+
*[
108+
'org.osgi.framework.Bundle',
109+
'org.osgi.framework.BundleActivator',
110+
'org.osgi.framework.BundleContext',
111+
'org.osgi.framework.BundleEvent',
112+
'org.osgi.framework.SynchronousBundleListener',
113+
'org.osgi.framework.wiring.BundleWire',
114+
'org.osgi.framework.wiring.BundleWiring',
115+
] + (BuildParams.runtimeJavaVersion < JavaVersion.VERSION_20) ? [] : [
116+
'jdk.incubator.vector.ByteVector',
117+
'jdk.incubator.vector.FloatVector',
118+
'jdk.incubator.vector.IntVector',
119+
'jdk.incubator.vector.ShortVector',
120+
'jdk.incubator.vector.Vector',
121+
'jdk.incubator.vector.VectorOperators',
122+
'jdk.incubator.vector.VectorSpecies'
123+
]
117124
)
118125
}
119126

server/build.gradle

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ tasks.named("processResources").configure {
257257

258258
tasks.named("thirdPartyAudit").configure {
259259
ignoreMissingClasses(
260+
*[
260261
// from com.fasterxml.jackson.dataformat.yaml.YAMLMapper (jackson-dataformat-yaml)
261262
'com.fasterxml.jackson.databind.ObjectMapper',
262263

@@ -385,7 +386,17 @@ tasks.named("thirdPartyAudit").configure {
385386
'org.slf4j.Logger',
386387
'org.slf4j.LoggerFactory',
387388
'reactor.blockhound.BlockHound$Builder',
388-
'reactor.blockhound.integration.BlockHoundIntegration'
389+
'reactor.blockhound.integration.BlockHoundIntegration',
390+
'com.google.common.geometry.S2LatLng'
391+
] + (BuildParams.runtimeJavaVersion < JavaVersion.VERSION_20) ? [] : [
392+
'jdk.incubator.vector.ByteVector',
393+
'jdk.incubator.vector.FloatVector',
394+
'jdk.incubator.vector.IntVector',
395+
'jdk.incubator.vector.ShortVector',
396+
'jdk.incubator.vector.Vector',
397+
'jdk.incubator.vector.VectorOperators',
398+
'jdk.incubator.vector.VectorSpecies'
399+
]
389400
)
390401
ignoreViolations(
391402
'com.google.protobuf.MessageSchema',

server/src/internalClusterTest/java/org/opensearch/discovery/ClusterManagerDisruptionIT.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858

5959
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
6060
import static org.hamcrest.Matchers.equalTo;
61+
import static org.hamcrest.Matchers.lessThan;
6162
import static org.hamcrest.Matchers.not;
63+
import static org.junit.Assume.assumeThat;
6264

6365
/**
6466
* Tests relating to the loss of the cluster-manager.
@@ -71,6 +73,7 @@ public class ClusterManagerDisruptionIT extends AbstractDisruptionTestCase {
7173
*/
7274
public void testClusterManagerNodeGCs() throws Exception {
7375
List<String> nodes = startCluster(3);
76+
assumeThat("Thread::resume / Thread::suspend are not supported anymore", Runtime.version(), lessThan(Runtime.Version.parse("20")));
7477

7578
String oldClusterManagerNode = internalCluster().getClusterManagerName();
7679
// a very long GC, but it's OK as we remove the disruption when it has had an effect

server/src/internalClusterTest/java/org/opensearch/discovery/StableClusterManagerDisruptionIT.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171

7272
import static java.util.Collections.singleton;
7373
import static org.hamcrest.Matchers.equalTo;
74+
import static org.hamcrest.Matchers.lessThan;
75+
import static org.junit.Assume.assumeThat;
7476

7577
/**
7678
* Tests relating to the loss of the cluster-manager, but which work with the default fault detection settings which are rather lenient and will
@@ -195,6 +197,8 @@ private void testFollowerCheckerAfterClusterManagerReelection(NetworkLinkDisrupt
195197
* following another elected cluster-manager node. These nodes should reject this cluster state and prevent them from following the stale cluster-manager.
196198
*/
197199
public void testStaleClusterManagerNotHijackingMajority() throws Exception {
200+
assumeThat("Thread::resume / Thread::suspend are not supported anymore", Runtime.version(), lessThan(Runtime.Version.parse("20")));
201+
198202
final List<String> nodes = internalCluster().startNodes(
199203
3,
200204
Settings.builder()

server/src/main/java/org/opensearch/common/util/concurrent/BaseFuture.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public abstract class BaseFuture<V> implements Future<V> {
7474
*
7575
* @throws InterruptedException if the current thread was interrupted before
7676
* or during the call (optional but recommended).
77-
* @throws CancellationException {@inheritDoc}
77+
* @throws CancellationException if the computation was cancelled
7878
*/
7979
@Override
8080
public V get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException, ExecutionException {
@@ -96,7 +96,7 @@ public V get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutEx
9696
*
9797
* @throws InterruptedException if the current thread was interrupted before
9898
* or during the call (optional but recommended).
99-
* @throws CancellationException {@inheritDoc}
99+
* @throws CancellationException if the computation was cancelled
100100
*/
101101
@Override
102102
public V get() throws InterruptedException, ExecutionException {

test/framework/src/main/java/org/opensearch/cluster/coordination/MockSinglePrioritizingExecutor.java

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,30 @@
4444
public class MockSinglePrioritizingExecutor extends PrioritizedOpenSearchThreadPoolExecutor {
4545

4646
public MockSinglePrioritizingExecutor(String name, DeterministicTaskQueue deterministicTaskQueue, ThreadPool threadPool) {
47-
super(name, 0, 1, 0L, TimeUnit.MILLISECONDS, r -> new Thread() {
48-
@Override
49-
public void start() {
50-
deterministicTaskQueue.scheduleNow(new Runnable() {
51-
@Override
52-
public void run() {
53-
try {
54-
r.run();
55-
} catch (KillWorkerError kwe) {
56-
// hacks everywhere
57-
}
47+
super(name, 0, 1, 0L, TimeUnit.MILLISECONDS, r -> {
48+
// This executor used to override Thread::start method so the actual runnable is
49+
// being scheduled in the scope of current thread of execution. In JDK-19, the Thread::start
50+
// is not called anymore (https://bugs.openjdk.org/browse/JDK-8292027) and there is no
51+
// suitable option to alter the executor's behavior in the similar way. The closest we
52+
// could get to is to schedule the runnable once the ThreadFactory is being asked to
53+
// allocate the new thread.
54+
deterministicTaskQueue.scheduleNow(new Runnable() {
55+
@Override
56+
public void run() {
57+
try {
58+
r.run();
59+
} catch (KillWorkerError kwe) {
60+
// hacks everywhere
5861
}
62+
}
5963

60-
@Override
61-
public String toString() {
62-
return r.toString();
63-
}
64-
});
65-
}
64+
@Override
65+
public String toString() {
66+
return r.toString();
67+
}
68+
});
69+
70+
return new Thread(() -> {});
6671
}, threadPool.getThreadContext(), threadPool.scheduler());
6772
}
6873

test/framework/src/test/java/org/opensearch/test/disruption/LongGCDisruptionTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
import static org.hamcrest.Matchers.containsString;
4949
import static org.hamcrest.Matchers.equalTo;
5050
import static org.hamcrest.Matchers.greaterThan;
51+
import static org.hamcrest.Matchers.lessThan;
52+
import static org.junit.Assume.assumeThat;
5153

5254
public class LongGCDisruptionTests extends OpenSearchTestCase {
5355

@@ -65,6 +67,8 @@ public void executeLocked(Runnable r) {
6567
}
6668

6769
public void testBlockingTimeout() throws Exception {
70+
assumeThat("Thread::resume / Thread::suspend are not supported anymore", Runtime.version(), lessThan(Runtime.Version.parse("20")));
71+
6872
final String nodeName = "test_node";
6973
LongGCDisruption disruption = new LongGCDisruption(random(), nodeName) {
7074
@Override
@@ -125,6 +129,8 @@ protected long getSuspendingTimeoutInMillis() {
125129
* but does keep retrying until all threads can be safely paused
126130
*/
127131
public void testNotBlockingUnsafeStackTraces() throws Exception {
132+
assumeThat("Thread::resume / Thread::suspend are not supported anymore", Runtime.version(), lessThan(Runtime.Version.parse("20")));
133+
128134
final String nodeName = "test_node";
129135
LongGCDisruption disruption = new LongGCDisruption(random(), nodeName) {
130136
@Override
@@ -179,6 +185,8 @@ protected Pattern[] getUnsafeClasses() {
179185
}
180186

181187
public void testBlockDetection() throws Exception {
188+
assumeThat("Thread::resume / Thread::suspend are not supported anymore", Runtime.version(), lessThan(Runtime.Version.parse("20")));
189+
182190
final String disruptedNodeName = "disrupted_node";
183191
final String blockedNodeName = "blocked_node";
184192
CountDownLatch waitForBlockDetectionResult = new CountDownLatch(1);

0 commit comments

Comments
 (0)