From 6bc45d7cba9de856778bd5b2fccba6922c5d1727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Galder=20Zamarren=CC=83o?= Date: Mon, 20 Apr 2020 14:02:39 +0200 Subject: [PATCH 1/3] Use a custom InitialContextFactoryBuilder to avoid JDK caching #8651 * Recent JDK changes have added caching of InitialContextFactory instances which results in creating classloaders on the fly. See JDK-8223260. * That's not allowed by Graal, so instead use a custom InitialContextFactoryBuilder to avoid the issue. --- .../ldap/QuarkusDirContextFactory.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/extensions/elytron-security-ldap/runtime/src/main/java/io/quarkus/elytron/security/ldap/QuarkusDirContextFactory.java b/extensions/elytron-security-ldap/runtime/src/main/java/io/quarkus/elytron/security/ldap/QuarkusDirContextFactory.java index 6dde3648e0826..307ff1f8df010 100644 --- a/extensions/elytron-security-ldap/runtime/src/main/java/io/quarkus/elytron/security/ldap/QuarkusDirContextFactory.java +++ b/extensions/elytron-security-ldap/runtime/src/main/java/io/quarkus/elytron/security/ldap/QuarkusDirContextFactory.java @@ -4,10 +4,15 @@ import java.security.PrivilegedAction; import java.util.Hashtable; +import javax.naming.Context; import javax.naming.NamingException; +import javax.naming.NoInitialContextException; import javax.naming.directory.DirContext; import javax.naming.directory.InitialDirContext; import javax.naming.ldap.InitialLdapContext; +import javax.naming.spi.InitialContextFactory; +import javax.naming.spi.InitialContextFactoryBuilder; +import javax.naming.spi.NamingManager; import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.NameCallback; @@ -107,6 +112,10 @@ private DirContext createDirContext(String securityPrincipal, char[] securityCre InitialLdapContext initialContext; try { + if (!NamingManager.hasInitialContextFactoryBuilder()) { + NamingManager.setInitialContextFactoryBuilder(new QuarkusInitialContextFactoryBuilder()); + } + initialContext = new InitialLdapContext(env, null); } catch (NamingException ne) { // log.debugf(ne, "Could not create [%s]. Failed to connect to LDAP server.", InitialLdapContext.class); @@ -148,4 +157,19 @@ private static T doPrivileged(final PrivilegedAction action) { return System.getSecurityManager() != null ? AccessController.doPrivileged(action) : action.run(); } + private static final class QuarkusInitialContextFactoryBuilder implements InitialContextFactoryBuilder { + @Override + public InitialContextFactory createInitialContextFactory(Hashtable environment) throws NamingException { + final String className = (String) environment.get(Context.INITIAL_CONTEXT_FACTORY); + try { + final ClassLoader cl = Thread.currentThread().getContextClassLoader(); + return (InitialContextFactory) Class.forName(className, true, cl).newInstance(); + } catch (Exception e) { + NoInitialContextException ne = new NoInitialContextException( + "Cannot instantiate class: " + className); + ne.setRootCause(e); + throw ne; + } + } + } } From 4ffc051c7c13d5de40c9b7cd028459c51421b5d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Galder=20Zamarren=CC=83o?= Date: Fri, 29 May 2020 11:25:37 +0200 Subject: [PATCH 2/3] Cut off path to Class serialization for all #9633 --- .../runtime/graal/JavaIOSubstitutions.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 core/runtime/src/main/java/io/quarkus/runtime/graal/JavaIOSubstitutions.java diff --git a/core/runtime/src/main/java/io/quarkus/runtime/graal/JavaIOSubstitutions.java b/core/runtime/src/main/java/io/quarkus/runtime/graal/JavaIOSubstitutions.java new file mode 100644 index 0000000000000..1b7e66746f6e4 --- /dev/null +++ b/core/runtime/src/main/java/io/quarkus/runtime/graal/JavaIOSubstitutions.java @@ -0,0 +1,25 @@ +package io.quarkus.runtime.graal; + +import java.io.ObjectStreamClass; + +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; + +@TargetClass(java.io.ObjectStreamClass.class) +@SuppressWarnings({ "unused" }) +final class Target_java_io_ObjectStreamClass { + + @Substitute + private static ObjectStreamClass lookup(Class cl, boolean all) { + throw new UnsupportedOperationException("Serialization of class definitions not supported"); + } + + private Target_java_io_ObjectStreamClass(final Class cl) { + throw new UnsupportedOperationException("Serialization of class definitions not supported"); + } + + private Target_java_io_ObjectStreamClass() { + throw new UnsupportedOperationException("Not supported"); + } + +} From edd539f29c305ab908ed6bcd315821e1e5beb137 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Fri, 15 May 2020 15:15:25 +0200 Subject: [PATCH 3/3] Upgrade GraalVM to 20.1.0 Note that we are still supporting 19.3.1 and 19.3.2 for now. I'm recommending either 19.3.2 or 20.1.0 in the error message. --- .github/workflows/ci-actions.yml | 2 +- .github/workflows/native-cron-build.yml | 4 ++-- bom/runtime/pom.xml | 2 +- build-parent/pom.xml | 2 +- .../src/main/java/io/quarkus/deployment/pkg/NativeConfig.java | 2 +- .../io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java | 4 ++-- independent-projects/bootstrap/pom.xml | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-actions.yml b/.github/workflows/ci-actions.yml index 99add5bcc84a6..d4e4226de83da 100644 --- a/.github/workflows/ci-actions.yml +++ b/.github/workflows/ci-actions.yml @@ -34,7 +34,7 @@ on: env: # Workaround testsuite locale issue LANG: en_US.UTF-8 - NATIVE_TEST_MAVEN_OPTS: "-B --settings .github/mvn-settings.xml --fail-at-end -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-native-image:19.3.1-java11 -Dtest-postgresql -Dtest-elasticsearch -Dtest-keycloak -Dtest-amazon-services -Dtest-mysql -Dtest-mariadb -Dmariadb.base_url='jdbc:mariadb://localhost:3308' -Dmariadb.url='jdbc:mariadb://localhost:3308/hibernate_orm_test' -Dtest-mssql -Dtest-vault -Dtest-neo4j -Dtest-kafka -Dnative-image.xmx=5g -Dnative -Dformat.skip install" + NATIVE_TEST_MAVEN_OPTS: "-B --settings .github/mvn-settings.xml --fail-at-end -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-native-image:20.1.0-java11 -Dtest-postgresql -Dtest-elasticsearch -Dtest-keycloak -Dtest-amazon-services -Dtest-mysql -Dtest-mariadb -Dmariadb.base_url='jdbc:mariadb://localhost:3308' -Dmariadb.url='jdbc:mariadb://localhost:3308/hibernate_orm_test' -Dtest-mssql -Dtest-vault -Dtest-neo4j -Dtest-kafka -Dnative-image.xmx=5g -Dnative -Dformat.skip install" JVM_TEST_MAVEN_OPTS: "-e -B --settings .github/mvn-settings.xml -Dtest-postgresql -Dtest-elasticsearch -Dtest-mysql -Dtest-mariadb -Dmariadb.base_url='jdbc:mariadb://localhost:3308' -Dmariadb.url='jdbc:mariadb://localhost:3308/hibernate_orm_test' -Dtest-mssql -Dtest-amazon-services -Dtest-vault -Dtest-neo4j -Dtest-kafka -Dtest-keycloak -Dformat.skip" DB_USER: hibernate_orm_test DB_PASSWORD: hibernate_orm_test diff --git a/.github/workflows/native-cron-build.yml b/.github/workflows/native-cron-build.yml index 6ae17aa3b20d5..c4cab0039c2ed 100644 --- a/.github/workflows/native-cron-build.yml +++ b/.github/workflows/native-cron-build.yml @@ -19,7 +19,7 @@ jobs: run: sudo systemctl stop mysql - name: Pull docker image - run: docker pull quay.io/quarkus/ubi-quarkus-native-image:19.3.1-java${{ matrix.java }} + run: docker pull quay.io/quarkus/ubi-quarkus-native-image:20.1.0-java${{ matrix.java }} - name: Set up JDK ${{ matrix.java }} # Uses sha for added security since tags can be updated @@ -54,7 +54,7 @@ jobs: run: mvn -B install -DskipTests -DskipITs -Dformat.skip - name: Run integration tests in native - run: mvn -B --settings .github/mvn-settings.xml verify -f integration-tests/pom.xml --fail-at-end -Dno-format -Ddocker -Dnative -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-native-image:19.3.1-java${{ matrix.java }} -Dtest-postgresql -Dtest-elasticsearch -Dtest-mysql -Dtest-amazon-services -Dtest-vault -Dtest-neo4j -Dtest-keycloak -Dtest-kafka -Dtest-mssql -Dtest-mariadb -Dmariadb.url="jdbc:mariadb://localhost:3308/hibernate_orm_test" + run: mvn -B --settings .github/mvn-settings.xml verify -f integration-tests/pom.xml --fail-at-end -Dno-format -Ddocker -Dnative -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-native-image:20.1.0-java${{ matrix.java }} -Dtest-postgresql -Dtest-elasticsearch -Dtest-mysql -Dtest-amazon-services -Dtest-vault -Dtest-neo4j -Dtest-keycloak -Dtest-kafka -Dtest-mssql -Dtest-mariadb -Dmariadb.url="jdbc:mariadb://localhost:3308/hibernate_orm_test" - name: Report if: always() diff --git a/bom/runtime/pom.xml b/bom/runtime/pom.xml index 2a9b26df6357c..84a406f6873f8 100644 --- a/bom/runtime/pom.xml +++ b/bom/runtime/pom.xml @@ -76,7 +76,7 @@ 3.6.0 2.1.0 - 19.3.1 + 20.1.0 1.0.3.Final 2.10.4 1.0.0.Final diff --git a/build-parent/pom.xml b/build-parent/pom.xml index 49d9795d41841..f37c1a934a41e 100644 --- a/build-parent/pom.xml +++ b/build-parent/pom.xml @@ -33,7 +33,7 @@ - 19.3.1 + 20.1.0 4.1.1 0.0.16 0.0.16 diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/NativeConfig.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/NativeConfig.java index e5b5f67bc0d5e..56795486db695 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/NativeConfig.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/NativeConfig.java @@ -140,7 +140,7 @@ public class NativeConfig { /** * The docker image to use to do the image build */ - @ConfigItem(defaultValue = "quay.io/quarkus/ubi-quarkus-native-image:19.3.1-java11") + @ConfigItem(defaultValue = "quay.io/quarkus/ubi-quarkus-native-image:20.1.0-java11") public String builderImage; /** diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java index e335db1144def..c4c6a945b23fe 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java @@ -377,11 +377,11 @@ private RuntimeException imageGenerationFailed(int exitValue, List comma private void checkGraalVMVersion(String version) { log.info("Running Quarkus native-image plugin on " + version); - final List obsoleteGraalVmVersions = Arrays.asList("1.0.0", "19.0.", "19.1.", "19.2.", "19.3.0"); + final List obsoleteGraalVmVersions = Arrays.asList("1.0.0", "19.0.", "19.1.", "19.2.", "19.3.0", "20.0."); final boolean vmVersionIsObsolete = obsoleteGraalVmVersions.stream().anyMatch(v -> version.contains(" " + v)); if (vmVersionIsObsolete) { throw new IllegalStateException("Out of date version of GraalVM detected: " + version + "." - + " Quarkus currently supports GraalVM 19.3.1 and 20.0.0. Please upgrade GraalVM to one of these versions."); + + " Quarkus currently supports GraalVM 19.3.2 and 20.1.0. Please upgrade GraalVM to one of these versions."); } } diff --git a/independent-projects/bootstrap/pom.xml b/independent-projects/bootstrap/pom.xml index 8e41a69931932..560a258650563 100644 --- a/independent-projects/bootstrap/pom.xml +++ b/independent-projects/bootstrap/pom.xml @@ -44,7 +44,7 @@ 7.3.1 1.2.6 1.0.4 - 19.3.1 + 20.1.0 2.6.0