From 505fc5492f42e57d4c494a60d70222fc14546f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Fri, 10 Mar 2023 14:45:08 +0100 Subject: [PATCH 1/2] Remove duplicate handling of oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource We already handle that in OracleMetadataOverrides --- .../quarkus/jdbc/oracle/deployment/OracleNativeImage.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleNativeImage.java b/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleNativeImage.java index 8778e677ca104..51053a2fb0765 100644 --- a/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleNativeImage.java +++ b/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleNativeImage.java @@ -3,7 +3,6 @@ import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; -import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; /** * @author Sanne Grinovero @@ -35,10 +34,4 @@ void reflection(BuildProducer reflectiveClass) { reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, "com.sun.jndi.rmi.registry.RegistryContextFactory")); } - @BuildStep - void runtimeInitialization(BuildProducer runtimeInitializedClass) { - runtimeInitializedClass - .produce(new RuntimeInitializedClassBuildItem("oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource")); - } - } From 77062838587b25c6c8a18dddda6e26f2995348b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Fri, 10 Mar 2023 14:48:24 +0100 Subject: [PATCH 2/2] Reinitialize oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource at runtime --- .../oracle/deployment/OracleMetadataOverrides.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleMetadataOverrides.java b/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleMetadataOverrides.java index fbabaecceb2d5..892ef190c539f 100644 --- a/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleMetadataOverrides.java +++ b/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleMetadataOverrides.java @@ -9,6 +9,7 @@ import io.quarkus.deployment.builditem.nativeimage.NativeImageAllowIncompleteClasspathBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; +import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem; import io.quarkus.maven.dependency.ArtifactKey; /** @@ -66,7 +67,8 @@ void build(BuildProducer reflectiveClass) { } @BuildStep - void runtimeInitializeDriver(BuildProducer runtimeInitialized) { + void runtimeInitializeDriver(BuildProducer runtimeInitialized, + BuildProducer runtimeReinitialized) { //These re-implement all the "--initialize-at-build-time" arguments found in the native-image.properties : // Override: the original metadata marks the drivers as "runtime initialized" but this makes it incompatible with @@ -93,10 +95,14 @@ void runtimeInitializeDriver(BuildProducer run runtimeInitialized.produce(new RuntimeInitializedClassBuildItem("oracle.net.nt.TcpMultiplexer")); runtimeInitialized.produce(new RuntimeInitializedClassBuildItem("oracle.net.nt.TcpMultiplexer")); runtimeInitialized.produce(new RuntimeInitializedClassBuildItem("oracle.net.nt.TcpMultiplexer$LazyHolder")); - runtimeInitialized - .produce(new RuntimeInitializedClassBuildItem("oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource")); - runtimeInitialized.produce(new RuntimeInitializedClassBuildItem( + + // Needs to be REinitialized to avoid problems when also using the Elasticsearch Java client + // See https://github.com/quarkusio/quarkus/issues/31624#issuecomment-1457706253 + runtimeReinitialized.produce(new RuntimeReinitializedClassBuildItem( + "oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource")); + runtimeReinitialized.produce(new RuntimeReinitializedClassBuildItem( "oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource$BlockReleaser")); + runtimeInitialized.produce(new RuntimeInitializedClassBuildItem("oracle.jdbc.xa.client.OracleXADataSource")); runtimeInitialized.produce(new RuntimeInitializedClassBuildItem("oracle.jdbc.replay.OracleXADataSourceImpl")); runtimeInitialized.produce(new RuntimeInitializedClassBuildItem("oracle.jdbc.datasource.OracleXAConnection"));