This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch camel-karaf-4.18.x
in repository https://gitbox.apache.org/repos/asf/camel-karaf.git
The following commit(s) were added to refs/heads/camel-karaf-4.18.x by this
push:
new 95b277dc0 fix(#707): reduce the fix to the service entry and add a
regression test (backport of #708) (#751)
95b277dc0 is described below
commit 95b277dc023396984237af28e5d469fe84e091fe
Author: JB Onofré <[email protected]>
AuthorDate: Mon Sep 7 11:00:47 2026 +0200
fix(#707): reduce the fix to the service entry and add a regression test
(backport of #708) (#751)
The class the service entry points at is already shipped, unchanged, in the
shaded camel-core-languages bundle, and Activator.BaseResolver loads it by
name from that file -- the @Language annotation is never read at runtime.
The
local copy of SimpleNoFileLanguage, the camel-api and camel-support
dependencies it needed to compile, and the Export-Package narrowing those
dependencies forced are therefore all unnecessary:
- The local copy shadowed the upstream class in the shaded jar, so a future
Camel change to SimpleNoFileLanguage would have been silently overridden
with no build failure.
- camel-api/camel-support were compile scope and, since the root pom sets
createDependencyReducedPom=false, would have leaked into the published pom
of the bundle and onto the classpath of every consumer.
- Restoring the conventional org.apache.camel* export with those
dependencies
present makes bnd inline all of camel-api and camel-support into the
bundle
(412 KB -> 1.9 MB) and duplicate-export packages that core/camel-api and
core/camel-support already provide.
Replace the shade IncludeResourceTransformer with a <resource> entry: the
module's <resources> block overrides Maven's default src/main/resources,
which
is why the file did not reach the bundle on its own. The transformer would
also have hard-failed the build with "duplicate entry" if Apache Camel ever
ships its own simple-no-file service file, whereas shade dedupes jar entries
silently.
Add the ASF licence header the file was missing; apache-rat rejected it,
which
breaks the release profile. java.util.Properties, used to parse the file,
ignores the # comments.
The resulting bundle is identical to the one built from main except for the
added service entry, with an unchanged Export-Package.
Add a Pax Exam regression test in tests/features/camel-core covering a
pollEnrich with a dynamic file endpoint, the scenario reported in the issue.
(cherry picked from commit 9d57b59d64ea1a808e13e9114a99e8074b0970ea)
---
core/camel-core-languages/pom.xml | 36 +++--------
.../language/simple/SimpleNoFileLanguage.java | 32 ----------
.../org/apache/camel/language/simple-no-file | 23 +++++++
.../camel/test/CamelPollEnrichRouteSupplier.java | 71 ++++++++++++++++++++++
.../apache/karaf/camel/itest/CamelCoreITest.java | 24 ++++++++
5 files changed, 125 insertions(+), 61 deletions(-)
diff --git a/core/camel-core-languages/pom.xml
b/core/camel-core-languages/pom.xml
index cba02aca1..d053acc0c 100644
--- a/core/camel-core-languages/pom.xml
+++ b/core/camel-core-languages/pom.xml
@@ -34,7 +34,7 @@
<properties>
<camel.osgi.export>
- org.apache.camel.language*;version=${camel-version}
+ org.apache.camel*;version=${camel-version}
</camel.osgi.export>
<camel.osgi.import>
*
@@ -42,28 +42,6 @@
</properties>
<dependencies>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-api</artifactId>
- <version>${camel-version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.camel</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-support</artifactId>
- <version>${camel-version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.camel</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core-languages</artifactId>
@@ -83,6 +61,12 @@
<directory>../../src/main/resources</directory>
<filtering>false</filtering>
</resource>
+ <!-- Declaring the module's own resources explicitly: the entry
above replaces
+ Maven's default resource directory, which would otherwise be
inherited. -->
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>false</filtering>
+ </resource>
</resources>
<plugins>
<plugin>
@@ -100,12 +84,6 @@
<include>org.apache.camel:camel-core-languages</include>
</includes>
</artifactSet>
- <transformers>
- <transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
-
<resource>META-INF/services/org/apache/camel/language/simple-no-file</resource>
-
<file>${project.basedir}/src/main/resources/META-INF/services/org/apache/camel/language/simple-no-file</file>
- </transformer>
- </transformers>
</configuration>
</execution>
</executions>
diff --git
a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleNoFileLanguage.java
b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleNoFileLanguage.java
deleted file mode 100644
index 982997544..000000000
---
a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleNoFileLanguage.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.language.simple;
-
-import org.apache.camel.spi.annotations.Language;
-
-/**
- * The {@link SimpleLanguage} but without support for using the file based
functions. This is used in some special
- * situations with EIPs such as poll/pollEnrich. This language is not exposed
as a public standard language and are only
- * intended for internal use.
- */
-@Language(value = "simple-no-file", functionsClass = SimpleConstants.class)
-public final class SimpleNoFileLanguage extends SimpleLanguage {
-
- public SimpleNoFileLanguage() {
- super(true);
- }
-}
diff --git
a/core/camel-core-languages/src/main/resources/META-INF/services/org/apache/camel/language/simple-no-file
b/core/camel-core-languages/src/main/resources/META-INF/services/org/apache/camel/language/simple-no-file
index 0c9b7e9ce..faf3f1aed 100644
---
a/core/camel-core-languages/src/main/resources/META-INF/services/org/apache/camel/language/simple-no-file
+++
b/core/camel-core-languages/src/main/resources/META-INF/services/org/apache/camel/language/simple-no-file
@@ -1 +1,24 @@
+#
+# 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.
+#
+# Camel-karaf specific: Apache Camel intentionally ships no service file for
this
+# language, because DefaultLanguageResolver resolves the name through a
hardcoded
+# branch instead. OsgiLanguageResolver has no such branch and looks the
language up
+# in the OSGi service registry, so without this entry "simple-no-file" cannot
be
+# resolved in Karaf and poll/pollEnrich with a simple expression fails with
+# NoSuchLanguageException. Keep this file across Camel upgrades. See issue
#707.
+#
class=org.apache.camel.language.simple.SimpleNoFileLanguage
diff --git
a/tests/features/camel-core/src/main/java/org/apache/karaf/camel/test/CamelPollEnrichRouteSupplier.java
b/tests/features/camel-core/src/main/java/org/apache/karaf/camel/test/CamelPollEnrichRouteSupplier.java
new file mode 100644
index 000000000..e092e3f10
--- /dev/null
+++
b/tests/features/camel-core/src/main/java/org/apache/karaf/camel/test/CamelPollEnrichRouteSupplier.java
@@ -0,0 +1,71 @@
+/*
+ * 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.karaf.camel.test;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.RouteDefinition;
+import
org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteSupplier;
+import org.apache.karaf.camel.itests.CamelRouteSupplier;
+import org.osgi.service.component.annotations.Component;
+
+/**
+ * Covers the resolution of the internal {@code simple-no-file} language in
OSGi.
+ * <p>
+ * When a {@code pollEnrich} is given a {@code simple} expression, {@code
PollEnrichReifier} rewrites it to the
+ * {@code simple-no-file} language, so starting this route makes the Camel
context resolve that name. Apache Camel
+ * ships no service file for it — {@code DefaultLanguageResolver} resolves it
through a hardcoded branch — whereas
+ * camel-karaf's {@code OsgiLanguageResolver} goes through the OSGi service
registry. Without the service file in
+ * the camel-core-languages bundle, this route fails to start with a {@code
NoSuchLanguageException}.
+ *
+ * @see <a href="https://github.com/apache/camel-karaf/issues/707">issue
#707</a>
+ */
+@Component(
+ name = "karaf-camel-poll-enrich-test",
+ immediate = true,
+ service = CamelRouteSupplier.class
+)
+public class CamelPollEnrichRouteSupplier extends
AbstractCamelSingleFeatureResultMockBasedRouteSupplier {
+
+ private static final String FILE_NAME_VARIABLE = "sourceFileName";
+ private static final String SOURCE_FILE_NAME = "poll-enrich-source.txt";
+ private static final long POLL_TIMEOUT_MS = 10000L;
+
+ public String getBaseDir() {
+ return
"%s/poll-enrich".formatted(System.getProperty("project.target"));
+ }
+
+ @Override
+ protected boolean consumerEnabled() {
+ // Everything happens in the producer route: it seeds the file, then
polls it back.
+ return false;
+ }
+
+ @Override
+ protected void configureProducer(RouteBuilder builder, RouteDefinition
producerRoute) {
+ String directory = getBaseDir();
+ producerRoute
+ .setVariable(FILE_NAME_VARIABLE,
builder.constant(SOURCE_FILE_NAME))
+ .setBody(builder.constant("OK"))
+ .toF("file:%s?fileName=${variable.%s}", directory,
FILE_NAME_VARIABLE)
+ // Clear the body so that only a successful enrichment can
restore it.
+ .setBody(builder.constant(""))
+ .pollEnrich()
+
.simple("file:%s?fileName=${variable.%s}&initialDelay=0&delay=100"
+ .formatted(directory, FILE_NAME_VARIABLE))
+ .timeout(POLL_TIMEOUT_MS)
+ .toF("mock:%s", getResultMockName());
+ }
+}
diff --git
a/tests/features/camel-core/src/test/java/org/apache/karaf/camel/itest/CamelCoreITest.java
b/tests/features/camel-core/src/test/java/org/apache/karaf/camel/itest/CamelCoreITest.java
index ae16cf8ab..8c25683af 100644
---
a/tests/features/camel-core/src/test/java/org/apache/karaf/camel/itest/CamelCoreITest.java
+++
b/tests/features/camel-core/src/test/java/org/apache/karaf/camel/itest/CamelCoreITest.java
@@ -14,6 +14,7 @@
package org.apache.karaf.camel.itest;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.karaf.camel.itests.AbstractCamelRouteWithBundleITest;
@@ -63,6 +64,11 @@ public class CamelCoreITest extends
AbstractCamelRouteWithBundleITest {
new CamelBeanITest(this).testRoutes();
}
+ @Test
+ public void testCamelPollEnrich() throws Exception {
+ new CamelPollEnrichITest(this).testRoutes();
+ }
+
public static class CamelFileITest extends
AbstractCamelSingleFeatureResultFileBasedRoute {
public CamelFileITest(CamelContextProvider provider, String baseDir) {
@@ -110,4 +116,22 @@ public class CamelCoreITest extends
AbstractCamelRouteWithBundleITest {
mock.expectedBodiesReceived("OK");
}
}
+
+ /**
+ * Asserts that a {@code pollEnrich} driven by a {@code simple} expression
starts and enriches, which requires the
+ * internal {@code simple-no-file} language to be resolvable in OSGi. See
issue #707.
+ */
+ public static class CamelPollEnrichITest extends
AbstractCamelSingleFeatureResultMockBasedRoute {
+
+ public CamelPollEnrichITest(CamelContextProvider provider) {
+ super(provider);
+ }
+
+ @Override
+ public void configureMock(MockEndpoint mock) {
+ // The route seeds a file and polls it back, so allow more
headroom than the 10s default.
+ mock.setResultWaitTime(TimeUnit.SECONDS.toMillis(30));
+ mock.expectedBodiesReceived("OK");
+ }
+ }
}
\ No newline at end of file