From 92b2b828f5e4139b5faaed4d0c20d512d62c8e0e Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 28 Nov 2022 10:17:56 +0100 Subject: [PATCH] Fix Java 17 test CI and remove Java 11 variant This commit fixes configuration and runtime issues with the Java 17 test CI variant and removes the Java 11 one, now that Spring Framework 5.3.x is in maintenance mode. --- ci/images/ci-image/Dockerfile | 1 - ci/images/get-jdk-url.sh | 6 --- ci/images/setup.sh | 2 +- ci/pipeline.yml | 40 +------------------ ci/scripts/check-project.sh | 2 +- gradle/toolchains.gradle | 19 ++------- .../SpringCoreBlockHoundIntegrationTests.java | 3 ++ .../util/StreamUtilsTests.java | 20 +++------- 8 files changed, 17 insertions(+), 76 deletions(-) diff --git a/ci/images/ci-image/Dockerfile b/ci/images/ci-image/Dockerfile index 0548a7c6b2..8c16e2bad2 100644 --- a/ci/images/ci-image/Dockerfile +++ b/ci/images/ci-image/Dockerfile @@ -5,7 +5,6 @@ ADD get-jdk-url.sh /get-jdk-url.sh RUN ./setup.sh java8 ENV JAVA_HOME /opt/openjdk/java8 -ENV JDK11 /opt/openjdk/java11 ENV JDK17 /opt/openjdk/java17 ENV PATH $JAVA_HOME/bin:$PATH diff --git a/ci/images/get-jdk-url.sh b/ci/images/get-jdk-url.sh index ecf692e517..bada29e91d 100755 --- a/ci/images/get-jdk-url.sh +++ b/ci/images/get-jdk-url.sh @@ -5,15 +5,9 @@ case "$1" in java8) echo "https://github.com/bell-sw/Liberica/releases/download/8u345+1/bellsoft-jdk8u345+1-linux-amd64.tar.gz" ;; - java11) - echo "https://github.com/bell-sw/Liberica/releases/download/11.0.16+8/bellsoft-jdk11.0.16+8-linux-amd64.tar.gz" - ;; java17) echo "https://github.com/bell-sw/Liberica/releases/download/17.0.4+8/bellsoft-jdk17.0.4+8-linux-amd64.tar.gz" ;; - java18) - echo "https://github.com/bell-sw/Liberica/releases/download/18.0.2+10/bellsoft-jdk18.0.2+10-linux-amd64.tar.gz" - ;; *) echo $"Unknown java version" exit 1 diff --git a/ci/images/setup.sh b/ci/images/setup.sh index f7add2e15c..e4c83004f7 100755 --- a/ci/images/setup.sh +++ b/ci/images/setup.sh @@ -20,7 +20,7 @@ curl https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.4/c mkdir -p /opt/openjdk pushd /opt/openjdk > /dev/null -for jdk in java8 java11 java17 +for jdk in java8 java17 do JDK_URL=$( /get-jdk-url.sh $jdk ) mkdir $jdk diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 5f7e91ba46..7442b767a8 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -125,14 +125,6 @@ resources: access_token: ((github-ci-status-token)) branch: ((branch)) context: build -- name: repo-status-jdk11-build - type: github-status-resource - icon: eye-check-outline - source: - repository: ((github-repo-name)) - access_token: ((github-ci-status-token)) - branch: ((branch)) - context: jdk11-build - name: repo-status-jdk17-build type: github-status-resource icon: eye-check-outline @@ -237,34 +229,6 @@ jobs: "zip.type": "schema" get_params: threads: 8 -- name: jdk11-build - serial: true - public: true - plan: - - get: ci-image - - get: git-repo - - get: every-morning - trigger: true - - put: repo-status-jdk11-build - params: { state: "pending", commit: "git-repo" } - - do: - - task: check-project - image: ci-image - file: git-repo/ci/tasks/check-project.yml - privileged: true - timeout: ((task-timeout)) - params: - TEST_TOOLCHAIN: 11 - <<: *build-project-task-params - on_failure: - do: - - put: repo-status-jdk11-build - params: { state: "failure", commit: "git-repo" } - - put: slack-alert - params: - <<: *slack-fail-params - - put: repo-status-jdk11-build - params: { state: "success", commit: "git-repo" } - name: jdk17-build serial: true public: true @@ -282,7 +246,7 @@ jobs: privileged: true timeout: ((task-timeout)) params: - TEST_TOOLCHAIN: 15 + TEST_TOOLCHAIN: 17 <<: *build-project-task-params on_failure: do: @@ -471,7 +435,7 @@ jobs: groups: - name: "builds" - jobs: ["build", "jdk11-build", "jdk17-build"] + jobs: ["build", "jdk17-build"] - name: "releases" jobs: ["stage-milestone", "stage-rc", "stage-release", "promote-milestone", "promote-rc", "promote-release", "create-github-release"] - name: "ci-images" diff --git a/ci/scripts/check-project.sh b/ci/scripts/check-project.sh index 7f6ca04cea..0620dc1716 100755 --- a/ci/scripts/check-project.sh +++ b/ci/scripts/check-project.sh @@ -4,6 +4,6 @@ set -e source $(dirname $0)/common.sh pushd git-repo > /dev/null -./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false -Porg.gradle.java.installations.fromEnv=JDK11,JDK15 \ +./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false -Porg.gradle.java.installations.fromEnv=JDK17 \ -PmainToolchain=${MAIN_TOOLCHAIN} -PtestToolchain=${TEST_TOOLCHAIN} --no-daemon --max-workers=4 check popd > /dev/null diff --git a/gradle/toolchains.gradle b/gradle/toolchains.gradle index 5573efa1a5..087f771f5c 100644 --- a/gradle/toolchains.gradle +++ b/gradle/toolchains.gradle @@ -81,6 +81,10 @@ plugins.withType(JavaPlugin) { javaLauncher = javaToolchains.launcherFor { languageVersion = testLanguageVersion } + if(testLanguageVersion == JavaLanguageVersion.of(17)) { + jvmArgs(["--add-opens=java.base/java.lang=ALL-UNNAMED", + "--add-opens=java.base/java.util=ALL-UNNAMED"]) + } } } } @@ -130,21 +134,6 @@ pluginManager.withPlugin("kotlin") { } } } - - if (testToolchainConfigured()) { - def testLanguageVersion = testToolchainLanguageVersion() - def compiler = javaToolchains.compilerFor { - languageVersion = testLanguageVersion - } - // See https://kotlinlang.org/docs/gradle.html#attributes-specific-for-jvm - def javaVersion = testLanguageVersion.toString() == '8' ? '1.8' : testLanguageVersion.toString() - compileTestKotlin { - kotlinOptions { - jvmTarget = javaVersion - jdkHome = compiler.get().metadata.installationPath.asFile.absolutePath - } - } - } } // Configure the JMH plugin to use the toolchain for generating and running JMH bytecode diff --git a/spring-core/src/test/java/org/springframework/core/SpringCoreBlockHoundIntegrationTests.java b/spring-core/src/test/java/org/springframework/core/SpringCoreBlockHoundIntegrationTests.java index c12a31cb60..6a9b9596c0 100644 --- a/spring-core/src/test/java/org/springframework/core/SpringCoreBlockHoundIntegrationTests.java +++ b/spring-core/src/test/java/org/springframework/core/SpringCoreBlockHoundIntegrationTests.java @@ -22,6 +22,7 @@ import java.util.concurrent.CompletableFuture; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledForJreRange; import reactor.blockhound.BlockHound; import reactor.core.scheduler.ReactorBlockHoundIntegration; import reactor.core.scheduler.Schedulers; @@ -31,6 +32,7 @@ import org.springframework.util.ConcurrentReferenceHashMap; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.condition.JRE.JAVA_14; /** * Tests to verify the spring-core BlockHound integration rules. @@ -38,6 +40,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; * @author Rossen Stoyanchev * @since 5.2.4 */ +@DisabledForJreRange(min = JAVA_14) public class SpringCoreBlockHoundIntegrationTests { @BeforeAll diff --git a/spring-core/src/test/java/org/springframework/util/StreamUtilsTests.java b/spring-core/src/test/java/org/springframework/util/StreamUtilsTests.java index 21f0829457..6558b8d7db 100644 --- a/spring-core/src/test/java/org/springframework/util/StreamUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/StreamUtilsTests.java @@ -33,8 +33,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; /** * Tests for {@link StreamUtils}. @@ -57,53 +55,47 @@ class StreamUtilsTests { @Test void copyToByteArray() throws Exception { - InputStream inputStream = spy(new ByteArrayInputStream(bytes)); + InputStream inputStream = new ByteArrayInputStream(bytes); byte[] actual = StreamUtils.copyToByteArray(inputStream); assertThat(actual).isEqualTo(bytes); - verify(inputStream, never()).close(); } @Test void copyToString() throws Exception { Charset charset = Charset.defaultCharset(); - InputStream inputStream = spy(new ByteArrayInputStream(string.getBytes(charset))); + InputStream inputStream = new ByteArrayInputStream(string.getBytes(charset)); String actual = StreamUtils.copyToString(inputStream, charset); assertThat(actual).isEqualTo(string); - verify(inputStream, never()).close(); } @Test void copyBytes() throws Exception { - ByteArrayOutputStream out = spy(new ByteArrayOutputStream()); + ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamUtils.copy(bytes, out); assertThat(out.toByteArray()).isEqualTo(bytes); - verify(out, never()).close(); } @Test void copyString() throws Exception { Charset charset = Charset.defaultCharset(); - ByteArrayOutputStream out = spy(new ByteArrayOutputStream()); + ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamUtils.copy(string, charset, out); assertThat(out.toByteArray()).isEqualTo(string.getBytes(charset)); - verify(out, never()).close(); } @Test void copyStream() throws Exception { - ByteArrayOutputStream out = spy(new ByteArrayOutputStream()); + ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamUtils.copy(new ByteArrayInputStream(bytes), out); assertThat(out.toByteArray()).isEqualTo(bytes); - verify(out, never()).close(); } @Test void copyRange() throws Exception { - ByteArrayOutputStream out = spy(new ByteArrayOutputStream()); + ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamUtils.copyRange(new ByteArrayInputStream(bytes), out, 0, 100); byte[] range = Arrays.copyOfRange(bytes, 0, 101); assertThat(out.toByteArray()).isEqualTo(range); - verify(out, never()).close(); } @Test