Skip to content

Commit

Permalink
SOLR-17321 JDK 21: delete obsolete checks mostly in build (#2868)
Browse files Browse the repository at this point in the history
* Build checks
* SSL checks not needed
* Lookup.ensureInitialized
  • Loading branch information
dsmiley authored Dec 28, 2024
1 parent c058ea5 commit 02cdf9e
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 235 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,6 @@ private void error(Element element, String message) {
fullMessage.append("): ");
fullMessage.append(message);

if (Runtime.version().feature() == 11 && element.getKind() == ElementKind.PACKAGE) {
// Avoid JDK 11 bug:
// https://issues.apache.org/jira/browse/LUCENE-9747
// https://bugs.openjdk.java.net/browse/JDK-8224082
reporter.print(Diagnostic.Kind.ERROR, fullMessage.toString());
} else {
reporter.print(Diagnostic.Kind.ERROR, element, fullMessage.toString());
}
reporter.print(Diagnostic.Kind.ERROR, element, fullMessage.toString());
}
}
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ apply from: file('gradle/java/javac.gradle')
apply from: file('gradle/testing/defaults-tests.gradle')
apply from: file('gradle/testing/randomization.gradle')
apply from: file('gradle/testing/fail-on-no-tests.gradle')
apply from: file('gradle/testing/fail-on-unsupported-jdk.gradle')
apply from: file('gradle/testing/alternative-jdk-support.gradle')
apply from: file('gradle/java/jar-manifest.gradle')
apply from: file('gradle/testing/retry-test.gradle')
Expand Down Expand Up @@ -206,7 +205,6 @@ apply from: file('gradle/hacks/global-exclude-dependencies.gradle')
apply from: file('gradle/hacks/gradle-archives.gradle')

apply from: file('gradle/hacks/wipe-temp.gradle')
apply from: file('gradle/hacks/hashmapAssertions.gradle')
apply from: file('gradle/hacks/turbocharge-jvm-opts.gradle')
apply from: file('gradle/hacks/dummy-outputs.gradle')

Expand Down
33 changes: 0 additions & 33 deletions gradle/hacks/hashmapAssertions.gradle

This file was deleted.

32 changes: 0 additions & 32 deletions gradle/testing/fail-on-unsupported-jdk.gradle

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,12 @@ private void init(ServletContext servletContext) {
}

// Do initial logs for experimental Lucene classes.
// TODO: Use "MethodHandles.lookup().ensureClassInitialized()" instead of "Class.forName()"
// once JDK 15+ is mandatory
final var lookup = MethodHandles.lookup();
Stream.of(MMapDirectory.class, VectorUtil.class)
.forEach(
cls -> {
try {
Class.forName(cls.getName());
lookup.ensureInitialized(cls);
} catch (ReflectiveOperationException re) {
throw new SolrException(
ErrorCode.SERVER_ERROR, "Could not load Lucene class: " + cls.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.solr.util;

import com.carrotsearch.randomizedtesting.RandomizedTest;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
Expand All @@ -27,7 +26,6 @@
import java.security.UnrecoverableKeyException;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import java.util.regex.Pattern;
import javax.net.ssl.SSLContext;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
Expand All @@ -38,7 +36,6 @@
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.SSLContexts;
import org.apache.lucene.util.Constants;
import org.apache.solr.client.solrj.embedded.SSLConfig;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.client.solrj.impl.HttpClientUtil.SocketFactoryRegistryProvider;
Expand Down Expand Up @@ -108,10 +105,6 @@ public SSLTestConfig(boolean useSsl, boolean clientAuth, boolean checkPeerName)
this.clientAuth = clientAuth;
this.checkPeerName = checkPeerName;

if (this.useSsl) {
assumeSslIsSafeToTest();
}

final String resourceName =
checkPeerName ? TEST_KEYSTORE_LOCALHOST_RESOURCE : TEST_KEYSTORE_BOGUSHOST_RESOURCE;
trustStore = keyStore = Resource.newClassPathResource(resourceName);
Expand Down Expand Up @@ -414,50 +407,4 @@ public void reseed(SecureRandomParameters params) {
/* NOOP */
}
}

/**
* Helper method for sanity checking if it's safe to use SSL on this JVM
*
* @see <a href="https://issues.apache.org/jira/browse/SOLR-12988">SOLR-12988</a>
* @throws org.junit.internal.AssumptionViolatedException if this JVM is known to have SSL
* problems
*/
public static void assumeSslIsSafeToTest() {
if (Constants.JVM_NAME.startsWith("OpenJDK")
|| Constants.JVM_NAME.startsWith("Java HotSpot(TM)")) {
RandomizedTest.assumeFalse(
"Test (or randomization for this seed) wants to use SSL, "
+ "but SSL is known to fail on your JVM: "
+ Constants.JVM_NAME
+ " / "
+ Constants.JVM_VERSION,
isOpenJdkJvmVersionKnownToHaveProblems(Constants.JVM_VERSION));
}
}

/**
* package visibility for tests
*
* @see Constants#JVM_VERSION
* @lucene.internal
*/
static boolean isOpenJdkJvmVersionKnownToHaveProblems(final String jvmVersion) {
// TODO: would be nice to replace with Runtime.Version once we don't have to
// worry about java8 support when backporting to branch_8x
return KNOWN_BAD_OPENJDK_JVMS.matcher(jvmVersion).matches();
}

private static final Pattern KNOWN_BAD_OPENJDK_JVMS =
Pattern.compile( // 11 to 11.0.2 were all definitely problematic
// - https://bugs.openjdk.java.net/browse/JDK-8212885
// - https://bugs.openjdk.java.net/browse/JDK-8213202
"(^11(\\.0(\\.0|\\.1|\\.2)?)?($|(\\_|\\+|\\-).*$))|"
+
// early (pre-ea) "testing" builds of 11, 12, and 13 were also buggy
// - https://bugs.openjdk.java.net/browse/JDK-8224829
"(^(11|12|13).*-testing.*$)|"
+
// So far, all 13-ea builds (up to 13-ea-26) have been buggy
// - https://bugs.openjdk.java.net/browse/JDK-8226338
"(^13-ea.*$)");
}

This file was deleted.

0 comments on commit 02cdf9e

Please sign in to comment.