diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 41af93f16be..1d0f0d7d106 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,10 +63,10 @@ jobs: matrix: os: - { - name: "Linux JDK 17", + name: "Linux JDK 21", runs-on: 'ubuntu-latest', java: { - version: 17 + version: 21 }, maven: { # Since we only start an Elasticsearch container on Linux we add the profile to enable container reuse here: @@ -77,10 +77,10 @@ jobs: # so we can't run Elasticsearch tests. # See https://github.com/actions/runner-images/issues/1143#issuecomment-972929995 - { - name: "Windows JDK 17", + name: "Windows JDK 21", runs-on: 'windows-latest', java: { - version: 17 + version: 21 }, maven: { args: '-Dtest.elasticsearch.skip=true' diff --git a/Jenkinsfile b/Jenkinsfile index 8621f44150f..bffafeb783a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -147,7 +147,7 @@ import org.hibernate.jenkins.pipeline.helpers.alternative.AlternativeMultiMap * settingsId: ... */ -@Field final String DEFAULT_JDK_TOOL = 'OpenJDK 17 Latest' +@Field final String DEFAULT_JDK_TOOL = 'OpenJDK 21 Latest' @Field final String MAVEN_TOOL = 'Apache Maven 3.9' // Default node pattern, to be used for resource-intensive stages. @@ -189,14 +189,13 @@ stage('Configure') { new JdkBuildEnvironment(version: '11', testCompilerTool: 'OpenJDK 11 Latest', condition: TestCondition.AFTER_MERGE), new JdkBuildEnvironment(version: '17', testCompilerTool: 'OpenJDK 17 Latest', + condition: TestCondition.AFTER_MERGE), + new JdkBuildEnvironment(version: '21', testCompilerTool: 'OpenJDK 21 Latest', condition: TestCondition.BEFORE_MERGE, isDefault: true), // We want to enable preview features when testing newer builds of OpenJDK: // even if we don't use these features, just enabling them can cause side effects // and it's useful to test that. - new JdkBuildEnvironment(version: '21', testCompilerTool: 'OpenJDK 21 Latest', - testLauncherArgs: '--enable-preview', - condition: TestCondition.AFTER_MERGE), new JdkBuildEnvironment(version: '22', testCompilerTool: 'OpenJDK 22 Latest', testLauncherArgs: '--enable-preview', condition: TestCondition.AFTER_MERGE), diff --git a/build/parents/build/pom.xml b/build/parents/build/pom.xml index 20f712cfcfc..52620fd9177 100644 --- a/build/parents/build/pom.xml +++ b/build/parents/build/pom.xml @@ -1014,6 +1014,10 @@ jdk-deprecated-16 jdk-deprecated-17 jdk-deprecated-18 + jdk-deprecated-19 + jdk-deprecated-20 + jdk-deprecated-21 + jdk-deprecated-22 jdk-internal-1.8 jdk-internal-9 @@ -1026,6 +1030,10 @@ jdk-internal-16 jdk-internal-17 jdk-internal-18 + jdk-internal-19 + jdk-internal-20 + jdk-internal-21 + jdk-internal-22 diff --git a/ci/dependency-update/Jenkinsfile b/ci/dependency-update/Jenkinsfile index 9753ddd950e..d4f6b47b885 100644 --- a/ci/dependency-update/Jenkinsfile +++ b/ci/dependency-update/Jenkinsfile @@ -37,7 +37,6 @@ Map settings() { ] case 'lucene10': return [ - testCompilerTool: 'OpenJDK 21 Latest', updateProperties: ['version.org.apache.lucene'], onlyRunTestDependingOn: ['hibernate-search-backend-lucene'], additionalMavenArgs: '-Dtest.elasticsearch.skip=true -pl :hibernate-search-engine,:hibernate-search-backend-lucene,:hibernate-search-util-internal-integrationtest-backend-lucene,:hibernate-search-v5migrationhelper-engine' @@ -76,7 +75,7 @@ def pullContainerImages() { } def withMavenWorkspace(Closure body) { - def actualJdk = settings().testCompilerTool == null ? 'OpenJDK 17 Latest' : settings().testCompilerTool + def actualJdk = settings().testCompilerTool == null ? 'OpenJDK 21 Latest' : settings().testCompilerTool withMaven(jdk: actualJdk, maven: 'Apache Maven 3.9', mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository', options: [ diff --git a/ci/performance/elasticsearch/Jenkinsfile b/ci/performance/elasticsearch/Jenkinsfile index 1c75114a57f..f527db60229 100644 --- a/ci/performance/elasticsearch/Jenkinsfile +++ b/ci/performance/elasticsearch/Jenkinsfile @@ -12,7 +12,7 @@ import groovy.transform.Field import org.hibernate.jenkins.pipeline.helpers.job.JobHelper @Field final String MAVEN_TOOL = 'Apache Maven 3.9' -@Field final String JDK_TOOL = 'OpenJDK 11 Latest' +@Field final String JDK_TOOL = 'OpenJDK 21 Latest' // Performance node pattern, to be used for stages involving performance tests. @Field final String PERFORMANCE_NODE_PATTERN = 'Performance' diff --git a/ci/performance/lucene/Jenkinsfile b/ci/performance/lucene/Jenkinsfile index 8dab45a2194..b58bb18c5d0 100644 --- a/ci/performance/lucene/Jenkinsfile +++ b/ci/performance/lucene/Jenkinsfile @@ -12,7 +12,7 @@ import groovy.transform.Field import org.hibernate.jenkins.pipeline.helpers.job.JobHelper @Field final String MAVEN_TOOL = 'Apache Maven 3.9' -@Field final String JDK_TOOL = 'OpenJDK 11 Latest' +@Field final String JDK_TOOL = 'OpenJDK 21 Latest' // Performance node pattern, to be used for stages involving performance tests. @Field final String PERFORMANCE_NODE_PATTERN = 'Performance' diff --git a/ci/release/Jenkinsfile b/ci/release/Jenkinsfile index 883c841bb26..bf09aa0bd2e 100644 --- a/ci/release/Jenkinsfile +++ b/ci/release/Jenkinsfile @@ -13,7 +13,7 @@ pipeline { } tools { maven 'Apache Maven 3.9' - jdk 'OpenJDK 17 Latest' + jdk 'OpenJDK 21 Latest' } options { buildDiscarder logRotator(daysToKeepStr: '30', numToKeepStr: '10') diff --git a/engine/src/main/java/org/hibernate/search/engine/environment/classpath/spi/DefaultResourceResolver.java b/engine/src/main/java/org/hibernate/search/engine/environment/classpath/spi/DefaultResourceResolver.java index eead34c48dc..320d2cb7cb5 100644 --- a/engine/src/main/java/org/hibernate/search/engine/environment/classpath/spi/DefaultResourceResolver.java +++ b/engine/src/main/java/org/hibernate/search/engine/environment/classpath/spi/DefaultResourceResolver.java @@ -7,6 +7,8 @@ import java.io.InputStream; import java.net.URL; +import org.hibernate.search.util.common.annotation.impl.SuppressForbiddenApis; + /** * Default implementation of {@code ClassResolver} relying on an {@link AggregatedClassLoader}. * @@ -25,6 +27,8 @@ private DefaultResourceResolver(AggregatedClassLoader aggregatedClassLoader) { } @Override + @SuppressForbiddenApis(reason = "URL constructors are deprecated in JDK 20+ in favor of using URI.toURL()," + + " but we want to preserve backward compatibility for now (see below).") public InputStream locateResourceStream(String name) { try { final InputStream stream = aggregatedClassLoader.getResourceAsStream( name ); @@ -42,6 +46,8 @@ public InputStream locateResourceStream(String name) { try { @SuppressWarnings("deprecation") // TODO: HSEARCH-4765 address the URL -> URI constructor change once the URLClassLoader stops using the URL constructor + // Main problem: would URI.create(stripped).toURL() fail, since `stripped` seems to be a relative URL? + // Do we even have test coverage for this line? InputStream resourceStream = new URL( stripped ).openStream(); return resourceStream; } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/FloatFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/FloatFieldTypeDescriptor.java index e275b2cd794..0a2e2498908 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/FloatFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/FloatFieldTypeDescriptor.java @@ -32,7 +32,7 @@ protected List createSingle() { 22.0f, 55f, 2500.5100000045f, - 1584514514.000000184f, + 1584514414.000000184f, Float.MAX_VALUE ); } @@ -69,7 +69,7 @@ protected List createUniquelyMatchableValues() { 0.0f, -0.0f, // Negative 0 is a different float 42.42f, - 1584514514.000000184f, + 1584514414.000000184f, -1.001f, 3.0f, 5.1f ); } diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/types/JavaNetURLPropertyTypeDescriptor.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/types/JavaNetURLPropertyTypeDescriptor.java index 29db37cbe9c..17e23d51fce 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/types/JavaNetURLPropertyTypeDescriptor.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/types/JavaNetURLPropertyTypeDescriptor.java @@ -17,6 +17,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; +import org.hibernate.search.util.impl.test.annotation.SuppressForbiddenApis; public class JavaNetURLPropertyTypeDescriptor extends PropertyTypeDescriptor { @@ -154,11 +155,10 @@ private static URL url(String spec) { } } - // TODO: HSEARCH-4765 To be removed when URL constructor is removed (JDK 20+). We keep it for now as users might still be using - // this constructor and we want to test such scenario + @SuppressForbiddenApis(reason = "We want to test 'new URL(...)' even in JDK 20+ where it's deprecated") private static URL urlAsNewUrl(String spec) { try { - @SuppressWarnings("deprecation") + @SuppressWarnings("deprecation") // We want to test 'new URL(...)' even in JDK 20+ where it's deprecated URL url = new URL( spec ); return url; } diff --git a/integrationtest/performance/pom.xml b/integrationtest/performance/pom.xml index 67069d91aaa..1ec573eaa53 100644 --- a/integrationtest/performance/pom.xml +++ b/integrationtest/performance/pom.xml @@ -12,14 +12,6 @@ Hibernate Search ITs - Performance - Parent POM Parent POM of Hibernate Search performance tests - - - 8 - ${java.home} - ${java-version.main.compiler.java_home}/bin/javac - - backend/base backend/lucene diff --git a/pom.xml b/pom.xml index 48ab3a32c2e..10781be2431 100644 --- a/pom.xml +++ b/pom.xml @@ -202,7 +202,7 @@ UTF-8 - 17 + 21 11 @@ -303,7 +303,7 @@ 10.17.0 2.16.2 3.3.2 - 1.10.0 + 1.11.0 2.24.1 1.0.0 0.9.0.M3 diff --git a/util/common/src/main/java/org/hibernate/search/util/common/jar/impl/CodeSource.java b/util/common/src/main/java/org/hibernate/search/util/common/jar/impl/CodeSource.java index d887222330a..c40f5d92864 100644 --- a/util/common/src/main/java/org/hibernate/search/util/common/jar/impl/CodeSource.java +++ b/util/common/src/main/java/org/hibernate/search/util/common/jar/impl/CodeSource.java @@ -25,6 +25,7 @@ import java.util.Map; import java.util.function.BiFunction; +import org.hibernate.search.util.common.annotation.impl.SuppressForbiddenApis; import org.hibernate.search.util.common.impl.Closer; import org.hibernate.search.util.common.impl.SuppressingCloser; import org.hibernate.search.util.common.impl.Throwables; @@ -75,6 +76,8 @@ class CodeSource implements Closeable { this.codeSourceLocation = codeSourceLocation; } + @SuppressForbiddenApis(reason = "URL constructors are deprecated in JDK 20+ in favor of using URI.toURL()," + + " but we need to start from URLs (not URIs) coming from java.security.CodeSource.") public InputStream readOrNull(String resourcePathString) throws IOException { Throwable exception = null; diff --git a/util/internal/test/common/src/main/java/org/hibernate/search/util/impl/test/SystemHelper.java b/util/internal/test/common/src/main/java/org/hibernate/search/util/impl/test/SystemHelper.java index 81ffee9fcd5..e27b6d0052f 100644 --- a/util/internal/test/common/src/main/java/org/hibernate/search/util/impl/test/SystemHelper.java +++ b/util/internal/test/common/src/main/java/org/hibernate/search/util/impl/test/SystemHelper.java @@ -5,6 +5,7 @@ package org.hibernate.search.util.impl.test; import java.io.BufferedReader; +import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -35,7 +36,7 @@ public static SystemPropertyRestorer setSystemProperty(String key, String value) public static Process runCommandWithInheritedIO(String... command) throws IOException { // We can't use `inheritIO()` in surefire as that would bypass surefire's - // output capturingand lead to warnings. + // output capturing and lead to warnings. // So we use an old-fashioned solution... Process process = new ProcessBuilder( command ) @@ -44,12 +45,16 @@ public static Process runCommandWithInheritedIO(String... command) throws IOExce // Drain the output/errors streams ExecutorService service = Executors.newFixedThreadPool( 2 ); - service.submit( () -> drain( process.getInputStream(), System.out::println ) ); - service.submit( () -> drain( process.getErrorStream(), System.err::println ) ); + try ( InputStream is = process.getInputStream(); InputStream es = process.getErrorStream(); + Closeable pool = service::shutdownNow ) { + service.submit( () -> drain( is, System.out::println ) ); + service.submit( () -> drain( es, System.err::println ) ); + service.shutdown(); - Awaitility.await( process + " termination" ) - .atMost( 1, TimeUnit.MINUTES ) - .until( () -> !process.isAlive() ); + Awaitility.await( process + " termination" ) + .atMost( 1, TimeUnit.MINUTES ) + .until( () -> !process.isAlive() ); + } return process; } @@ -57,7 +62,7 @@ public static Process runCommandWithInheritedIO(String... command) throws IOExce private static void drain(InputStream stream, Consumer consumer) { try ( InputStreamReader in = new InputStreamReader( stream, Charsets.UTF_8 ); BufferedReader bufferedReader = new BufferedReader( in ); ) { - bufferedReader.lines().forEach( System.out::println ); + bufferedReader.lines().forEach( consumer ); } catch (IOException e) { throw new RuntimeException( e );