Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix native compilation when using quarkus-jdbc-oracle with elasticsearch-java #31770

Merged
merged 2 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -66,7 +67,8 @@ void build(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
}

@BuildStep
void runtimeInitializeDriver(BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitialized) {
void runtimeInitializeDriver(BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitialized,
BuildProducer<RuntimeReinitializedClassBuildItem> 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
Expand All @@ -93,10 +95,14 @@ void runtimeInitializeDriver(BuildProducer<RuntimeInitializedClassBuildItem> 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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down Expand Up @@ -35,10 +34,4 @@ void reflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, "com.sun.jndi.rmi.registry.RegistryContextFactory"));
}

@BuildStep
void runtimeInitialization(BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitializedClass) {
runtimeInitializedClass
.produce(new RuntimeInitializedClassBuildItem("oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource"));
}

}