You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2026/04/23 13:35:04 UTC
(camel-quarkus) branch camel-main updated: Fix consul native build
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch camel-main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/camel-main by this push:
new 8a0005a667 Fix consul native build
8a0005a667 is described below
commit 8a0005a667170c4eed8466e0d32654341fd5a0ab
Author: James Netherton <ja...@gmail.com>
AuthorDate: Thu Apr 23 14:34:43 2026 +0100
Fix consul native build
---
.../consul/deployment/ConsulProcessor.java | 6 +++
extensions/consul/runtime/pom.xml | 5 +++
.../consul/graal/ConsulBuilderSubstitutions.java | 45 ++++++++++++++++++++++
3 files changed, 56 insertions(+)
diff --git a/extensions/consul/deployment/src/main/java/org/apache/camel/quarkus/component/consul/deployment/ConsulProcessor.java b/extensions/consul/deployment/src/main/java/org/apache/camel/quarkus/component/consul/deployment/ConsulProcessor.java
index ac2cf5ba13..71f0a46c73 100644
--- a/extensions/consul/deployment/src/main/java/org/apache/camel/quarkus/component/consul/deployment/ConsulProcessor.java
+++ b/extensions/consul/deployment/src/main/java/org/apache/camel/quarkus/component/consul/deployment/ConsulProcessor.java
@@ -19,6 +19,8 @@ package org.apache.camel.quarkus.component.consul.deployment;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
+import org.kiwiproject.consul.UnixDomainSocketFactory;
class ConsulProcessor {
private static final String FEATURE = "camel-consul";
@@ -33,4 +35,8 @@ class ConsulProcessor {
return new ExtensionSslNativeSupportBuildItem(FEATURE);
}
+ @BuildStep
+ RuntimeInitializedClassBuildItem runtimeInitializedClasses() {
+ return new RuntimeInitializedClassBuildItem(UnixDomainSocketFactory.class.getName());
+ }
}
diff --git a/extensions/consul/runtime/pom.xml b/extensions/consul/runtime/pom.xml
index 62a2e1de33..b064baf173 100644
--- a/extensions/consul/runtime/pom.xml
+++ b/extensions/consul/runtime/pom.xml
@@ -51,6 +51,11 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-consul</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.graalvm.sdk</groupId>
+ <artifactId>nativeimage</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/extensions/consul/runtime/src/main/java/org/apache/camel/quarkus/component/consul/graal/ConsulBuilderSubstitutions.java b/extensions/consul/runtime/src/main/java/org/apache/camel/quarkus/component/consul/graal/ConsulBuilderSubstitutions.java
new file mode 100644
index 0000000000..de364c0b8c
--- /dev/null
+++ b/extensions/consul/runtime/src/main/java/org/apache/camel/quarkus/component/consul/graal/ConsulBuilderSubstitutions.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.consul.graal;
+
+import java.nio.file.Path;
+import java.util.function.BooleanSupplier;
+
+import com.oracle.svm.core.annotate.Substitute;
+import com.oracle.svm.core.annotate.TargetClass;
+import okhttp3.OkHttpClient;
+import org.kiwiproject.consul.Consul;
+
+@TargetClass(value = Consul.Builder.class, onlyWith = { ConsulBuilderSubstitutions.JUnixSocketIsAbsent.class })
+final class ConsulBuilderSubstitutions {
+ @Substitute
+ static void addUnixDomainSocketFactory(Path unixSocketPath, OkHttpClient.Builder builder) {
+ // NoOp
+ }
+
+ static final class JUnixSocketIsAbsent implements BooleanSupplier {
+ @Override
+ public boolean getAsBoolean() {
+ try {
+ Thread.currentThread().getContextClassLoader().loadClass("org.newsclub.net.unix.AFUNIXSocket");
+ return false;
+ } catch (ClassNotFoundException e) {
+ return true;
+ }
+ }
+ }
+}