This is an automated email from the ASF dual-hosted git repository. JiriOndrusek pushed a commit to branch camel-main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 305edadbece62f58436f43eba48eccb3a4144a15 Author: jiriOndrusek-agent <[email protected]> AuthorDate: Thu Nov 26 07:34:38 2026 +0000 [camel-main] oauth: fix native build without camel-http-common and camel-netty-http camel-oauth reads request headers through ServletHttpRequestHeaders and NettyHttpRequestHeaders, which reference HttpMessage and NettyHttpMessage from the provided camel-http-common and camel-netty-http. Substitute them with no-op readers when those transports are absent, as they are only called for a message of their own type. Co-Authored-By: Claude Opus 5.5 <[email protected]> --- extensions/oauth/runtime/pom.xml | 5 ++ .../graal/HttpRequestHeadersSubstitutions.java | 78 ++++++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/extensions/oauth/runtime/pom.xml b/extensions/oauth/runtime/pom.xml index 441788732e7..901604ca664 100644 --- a/extensions/oauth/runtime/pom.xml +++ b/extensions/oauth/runtime/pom.xml @@ -50,6 +50,11 @@ <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-support-httpclient5</artifactId> </dependency> + <dependency> + <groupId>org.graalvm.sdk</groupId> + <artifactId>nativeimage</artifactId> + <scope>provided</scope> + </dependency> </dependencies> <build> diff --git a/extensions/oauth/runtime/src/main/java/org/apache/camel/quarkus/component/oauth/graal/HttpRequestHeadersSubstitutions.java b/extensions/oauth/runtime/src/main/java/org/apache/camel/quarkus/component/oauth/graal/HttpRequestHeadersSubstitutions.java new file mode 100644 index 00000000000..886c88f62c1 --- /dev/null +++ b/extensions/oauth/runtime/src/main/java/org/apache/camel/quarkus/component/oauth/graal/HttpRequestHeadersSubstitutions.java @@ -0,0 +1,78 @@ +/* + * 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.oauth.graal; + +import java.util.List; +import java.util.Optional; +import java.util.function.BooleanSupplier; + +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; +import org.apache.camel.Message; + +/** + * Removes references to the optional camel-http-common and camel-netty-http from camel-oauth. Their request header + * readers are only called for a message of their own transport, so they are never reached when it is absent. + */ +final class HttpRequestHeadersSubstitutions { + static final String SERVLET_HTTP_MESSAGE = "org.apache.camel.http.common.HttpMessage"; + static final String NETTY_HTTP_MESSAGE = "org.apache.camel.component.netty.http.NettyHttpMessage"; + + static boolean isAbsent(String className) { + try { + Thread.currentThread().getContextClassLoader().loadClass(className); + return false; + } catch (ClassNotFoundException e) { + return true; + } + } + + static final class CamelHttpCommonAbsent implements BooleanSupplier { + @Override + public boolean getAsBoolean() { + return isAbsent(SERVLET_HTTP_MESSAGE); + } + } + + static final class CamelNettyHttpAbsent implements BooleanSupplier { + @Override + public boolean getAsBoolean() { + return isAbsent(NETTY_HTTP_MESSAGE); + } + } +} + +@TargetClass(className = "org.apache.camel.oauth.ServletHttpRequestHeaders", onlyWith = HttpRequestHeadersSubstitutions.CamelHttpCommonAbsent.class) +final class Target_org_apache_camel_oauth_ServletHttpRequestHeaders { + @Substitute + static Optional<List<String>> values(Message message, String name) { + return Optional.empty(); + } + + @Substitute + static Optional<List<String>> valuesOfSpringBootMessage(Message message, String name) { + return Optional.empty(); + } +} + +@TargetClass(className = "org.apache.camel.oauth.NettyHttpRequestHeaders", onlyWith = HttpRequestHeadersSubstitutions.CamelNettyHttpAbsent.class) +final class Target_org_apache_camel_oauth_NettyHttpRequestHeaders { + @Substitute + static Optional<List<String>> values(Message message, String name) { + return Optional.empty(); + } +}
