You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "davsclaus (via GitHub)" <gi...@apache.org> on 2026/09/18 08:04:27 UTC
[PR] chore: camel-jbang - the bean class check honours the known dependencies camel run downloads, and says how to declare an unknown one [camel]
davsclaus opened a new pull request, #26574:
URL: https://github.com/apache/camel/pull/26574
A bean declared in YAML with a class that is not on the CLI classpath, such as `#class:org.postgresql.ds.PGSimpleDataSource` or the Artemis `ActiveMQConnectionFactory`, was reported by `camel validate` and the write tool as "class ... was not found", while `camel run` resolves exactly these classes through `camel-main-known-dependencies.properties`, downloads the jar and starts the route. The validator contradicted the runtime.
The check now loads the same two mapping files camel-kamelet-main uses (`camel-main-known-dependencies.properties`, `camel-component-known-dependencies.properties`) and matches the class name and then each enclosing package, as `KnownDependenciesResolver.findGav` does; a mapped class is not an error. For a class in no mapping the message says how to declare the dependency:
```
class com.zaxxer.hikari.HikariDataSourceX was not found (check the package name; a class of your own goes in a .java file next to the route; a class from another library needs its dependency declared, camel.jbang.dependencies=<groupId>:<artifactId>:<version> in application.properties or --dep on camel run)
```
Two tests: the Postgres datasource and the Artemis connection factory pass without a dependency declared; a class from an unknown library gets the declaration hint. camel-jbang-core already depends on camel-kamelet-main, so the mapping files are on the classpath.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Bp3538HRBPMQkb5ta9xRaj
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: camel-jbang - the bean class check honours the known dependencies camel run downloads, and says how to declare an unknown one [camel]
Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #26574:
URL: https://github.com/apache/camel/pull/26574#discussion_r4045125685
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/BeanRefChecks.java:
##########
@@ -340,6 +345,48 @@ static int indentOf(String line) {
* A class named with its package that is neither next to the route nor on the CLI classpath: the wrong package
* (org.apache.camel.support.StringAggregationStrategy) or a missing dependency. Null when the class is fine.
*/
+ /**
+ * The classes camel run resolves to a Maven dependency and downloads on demand (camel-kamelet-main's
+ * camel-main-known-dependencies.properties, camel-component-known-dependencies.properties and the generated
+ * camel-thirdparty-known-dependencies.properties of CAMEL-24809), so a #class:org.postgresql.ds.PGSimpleDataSource
+ * bean is fine without a dependency declared even though the class is not on the CLI classpath. Matched the way the
+ * runtime matches: the class name, then each enclosing package.
+ */
Review Comment:
⚠️ **Orphaned Javadoc — still not fixed**
The old `/** A class named with its package… */` (lines 344–347) was the Javadoc for `classNotFound()`. The new field and its own Javadoc were inserted between that comment and its method, so the old comment still floats detached from everything — it now documents neither the field nor `classNotFound()`.
Fix: move the old comment down so it sits directly above `static String classNotFound(…)`, and keep the field's Javadoc above the field.
```suggestion
* The classes camel run resolves to a Maven dependency and downloads on demand (camel-kamelet-main's
* camel-main-known-dependencies.properties, camel-component-known-dependencies.properties and the generated
* camel-thirdparty-known-dependencies.properties of CAMEL-24809), so a #class:org.postgresql.ds.PGSimpleDataSource
* bean is fine without a dependency declared even though the class is not on the CLI classpath. Matched the way the
* runtime matches: the class name, then each enclosing package.
*/
```
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/BeanRefChecks.java:
##########
@@ -340,6 +345,48 @@ static int indentOf(String line) {
* A class named with its package that is neither next to the route nor on the CLI classpath: the wrong package
* (org.apache.camel.support.StringAggregationStrategy) or a missing dependency. Null when the class is fine.
*/
+ /**
+ * The classes camel run resolves to a Maven dependency and downloads on demand (camel-kamelet-main's
+ * camel-main-known-dependencies.properties, camel-component-known-dependencies.properties and the generated
+ * camel-thirdparty-known-dependencies.properties of CAMEL-24809), so a #class:org.postgresql.ds.PGSimpleDataSource
+ * bean is fine without a dependency declared even though the class is not on the CLI classpath. Matched the way the
+ * runtime matches: the class name, then each enclosing package.
+ */
+ private static volatile Map<String, String> knownDependencies;
Review Comment:
⚠️ **Data race — comment still missing**
The lock-free lazy initialiser (`volatile` field, no `synchronized`) is correct but not obviously so: two threads can both read `null`, both build a `HashMap` independently, and the last `volatile` write wins — the maps are identical so correctness holds.
Without a comment, every static analyser and future reviewer will flag this as an unsafe publication. Add:
```suggestion
// Intentional benign race: two threads may both initialise this; the last volatile-write wins.
// Correctness holds because the maps are built from immutable classpath resources and are identical.
private static volatile Map<String, String> knownDependencies;
```
##########
dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/SourceValidatorBeanRefsTest.java:
##########
@@ -350,6 +350,43 @@ void aClassInTheWrongPackageIsReported(@TempDir Path dir) throws IOException {
.contains("did you mean org.apache.camel.processor.aggregate.StringAggregationStrategy?");
}
+ @Test
+ void aClassCamelRunDownloadsIsNotReportedAsMissing(@TempDir Path dir) throws IOException {
+ // the Postgres datasource and the Artemis connection factory are not on the CLI classpath, but camel run
+ // resolves them to their Maven dependency (camel-main-known-dependencies.properties) and downloads it, so a
+ // bean of that type runs; the validator must not contradict the runtime
+ List<String> msgs = SourceValidator.validate("r.camel.yaml", """
+ - beans:
+ - name: postgresDS
+ type: "#class:org.postgresql.ds.PGSimpleDataSource"
+ properties:
+ url: "jdbc:postgresql://localhost:5432/postgres"
+ - name: artemisCF
+ type: "#class:org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory"
+ - route:
+ from:
+ uri: "timer:tick?period=1000"
+ steps:
+ - to:
+ uri: "sql:select 1?dataSource=#postgresDS"
+ """, CATALOG, null, dir);
+ assertThat(msgs).isEmpty();
+ assertThat(BeanRefChecks.knownDependency("org.postgresql.ds.PGSimpleDataSource"))
+ .startsWith("org.postgresql:postgresql");
+ assertThat(BeanRefChecks.knownDependency("com.example.NoSuchThing")).isNull();
Review Comment:
⚠️ **Missing fallback test — still not added**
The existing test asserts `.startsWith("org.postgresql:postgresql")` — it only passes because the properties files are on the test classpath. The `catch (Exception e) { /* optimisation */ }` path (files absent from classpath) is never exercised.
Add a test that resets the cache and calls `knownDependency()` in an isolated classloader (or just with a thread-context classloader that has no properties files). Without it, a deployment that somehow excludes `camel-kamelet-main` at runtime will produce a `NullPointerException` or wrong behaviour and no test will catch the regression.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: camel-jbang - the bean class check honours the known dependencies camel run downloads, and says how to declare an unknown one [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #26574:
URL: https://github.com/apache/camel/pull/26574#issuecomment-5727114064
:star2: Thank you for your contribution to the Apache Camel project! :star2:
:robot: CI automation will test this PR automatically.
:camel: Apache Camel Committers, please review the following items:
* First-time contributors **require MANUAL approval** for the GitHub Actions to run
* You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
* You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
* Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
:warning: Be careful when sharing logs. Review their contents before sharing them publicly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: camel-jbang - the bean class check honours the known dependencies camel run downloads, and says how to declare an unknown one [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #26574:
URL: https://github.com/apache/camel/pull/26574
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: camel-jbang - the bean class check honours the known dependencies camel run downloads, and says how to declare an unknown one [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #26574:
URL: https://github.com/apache/camel/pull/26574#discussion_r4046113606
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/BeanRefChecks.java:
##########
@@ -337,8 +342,51 @@ static int indentOf(String line) {
}
/**
- * A class named with its package that is neither next to the route nor on the CLI classpath: the wrong package
- * (org.apache.camel.support.StringAggregationStrategy) or a missing dependency. Null when the class is fine.
+ * The classes camel run resolves to a Maven dependency and downloads on demand (camel-kamelet-main's
+ * camel-main-known-dependencies.properties, camel-component-known-dependencies.properties and the generated
+ * camel-thirdparty-known-dependencies.properties of CAMEL-24809), so a #class:org.postgresql.ds.PGSimpleDataSource
+ * bean is fine without a dependency declared even though the class is not on the CLI classpath. Matched the way the
+ * runtime matches: the class name, then each enclosing package.
+ */
+ private static volatile Map<String, String> knownDependencies;
+
+ static String knownDependency(String fqcn) {
+ Map<String, String> known = knownDependencies;
+ if (known == null) {
+ known = new HashMap<>();
+ for (String name : new String[] {
+ "camel-main-known-dependencies.properties", "camel-component-known-dependencies.properties",
+ "camel-thirdparty-known-dependencies.properties" }) {
+ try {
+ Enumeration<URL> resources = BeanRefChecks.class.getClassLoader().getResources(name);
+ while (resources.hasMoreElements()) {
+ try (InputStream is = resources.nextElement().openStream()) {
+ Properties prop = new Properties();
+ prop.load(is);
+ for (String key : prop.stringPropertyNames()) {
+ known.put(key, prop.getProperty(key));
+ }
+ }
+ }
+ } catch (Exception e) {
+ // the mapping is an optimisation of the message, not a requirement
Review Comment:
Swallowing every exception matches the runtime's loader (`KnownDependenciesResolver.doLoadKnownDependencies` does the same), and these check classes carry no logger, so fine as is; worth a debug line if a logger is ever added here.
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/BeanRefChecks.java:
##########
@@ -337,8 +342,51 @@ static int indentOf(String line) {
}
/**
- * A class named with its package that is neither next to the route nor on the CLI classpath: the wrong package
- * (org.apache.camel.support.StringAggregationStrategy) or a missing dependency. Null when the class is fine.
+ * The classes camel run resolves to a Maven dependency and downloads on demand (camel-kamelet-main's
+ * camel-main-known-dependencies.properties, camel-component-known-dependencies.properties and the generated
+ * camel-thirdparty-known-dependencies.properties of CAMEL-24809), so a #class:org.postgresql.ds.PGSimpleDataSource
+ * bean is fine without a dependency declared even though the class is not on the CLI classpath. Matched the way the
+ * runtime matches: the class name, then each enclosing package.
+ */
+ private static volatile Map<String, String> knownDependencies;
+
+ static String knownDependency(String fqcn) {
+ Map<String, String> known = knownDependencies;
+ if (known == null) {
+ known = new HashMap<>();
+ for (String name : new String[] {
+ "camel-main-known-dependencies.properties", "camel-component-known-dependencies.properties",
+ "camel-thirdparty-known-dependencies.properties" }) {
+ try {
+ Enumeration<URL> resources = BeanRefChecks.class.getClassLoader().getResources(name);
+ while (resources.hasMoreElements()) {
+ try (InputStream is = resources.nextElement().openStream()) {
+ Properties prop = new Properties();
+ prop.load(is);
+ for (String key : prop.stringPropertyNames()) {
+ known.put(key, prop.getProperty(key));
+ }
+ }
+ }
+ } catch (Exception e) {
+ // the mapping is an optimisation of the message, not a requirement
+ }
+ }
+ knownDependencies = known;
+ }
+ String prefix = fqcn;
+ String gav = known.get(prefix);
+ while (gav == null && prefix.lastIndexOf('.') != -1) {
Review Comment:
A typo inside a mapped package is no longer caught here: `org.postgresql.ds.PGSimpleDataSourc` matches `org.postgresql`, the validator stays silent, and the runtime downloads the driver and then fails at startup with class not found. That is the runtime resolver's own behaviour and the validator is meant to agree with it, but it is a small loss against the previous check. A later improvement could open the jar when it is already in the local repository and check the class is in it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: camel-jbang - the bean class check honours the known dependencies camel run downloads, and says how to declare an unknown one [camel]
Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #26574:
URL: https://github.com/apache/camel/pull/26574#discussion_r4044970563
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/BeanRefChecks.java:
##########
@@ -340,6 +345,46 @@ static int indentOf(String line) {
* A class named with its package that is neither next to the route nor on the CLI classpath: the wrong package
* (org.apache.camel.support.StringAggregationStrategy) or a missing dependency. Null when the class is fine.
*/
+ /**
+ * The classes camel run resolves to a Maven dependency and downloads on demand (camel-kamelet-main's
+ * camel-main-known-dependencies.properties and camel-component-known-dependencies.properties), so a
+ * #class:org.postgresql.ds.PGSimpleDataSource bean is fine without a dependency declared even though the class is
+ * not on the CLI classpath. Matched the way the runtime matches: the class name, then each enclosing package.
+ */
+ private static volatile Map<String, String> knownDependencies;
Review Comment:
⚠️ **Orphaned Javadoc / misplaced comment**
The existing `/** A class named with its package... */` comment immediately above (lines 345–347) was the Javadoc for `classNotFound()`. The new code inserts the `knownDependencies` field (with its own Javadoc block) between that comment and its method, so the old comment now floats as an unattached Javadoc — it documents nothing and will confuse anyone reading the file.
Fix: move the old comment down so it sits directly above `static String classNotFound(...)`, or fold the two Javadoc blocks into one (since they're adjacent concepts). Currently `classNotFound` ends up with no Javadoc at all.
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/BeanRefChecks.java:
##########
@@ -340,6 +345,46 @@ static int indentOf(String line) {
* A class named with its package that is neither next to the route nor on the CLI classpath: the wrong package
* (org.apache.camel.support.StringAggregationStrategy) or a missing dependency. Null when the class is fine.
*/
+ /**
+ * The classes camel run resolves to a Maven dependency and downloads on demand (camel-kamelet-main's
+ * camel-main-known-dependencies.properties and camel-component-known-dependencies.properties), so a
+ * #class:org.postgresql.ds.PGSimpleDataSource bean is fine without a dependency declared even though the class is
+ * not on the CLI classpath. Matched the way the runtime matches: the class name, then each enclosing package.
+ */
+ private static volatile Map<String, String> knownDependencies;
+
+ static String knownDependency(String fqcn) {
+ Map<String, String> known = knownDependencies;
+ if (known == null) {
+ known = new HashMap<>();
+ for (String name : new String[] {
+ "camel-main-known-dependencies.properties", "camel-component-known-dependencies.properties" }) {
+ try {
+ Enumeration<URL> resources = BeanRefChecks.class.getClassLoader().getResources(name);
+ while (resources.hasMoreElements()) {
+ try (InputStream is = resources.nextElement().openStream()) {
+ Properties prop = new Properties();
+ prop.load(is);
+ for (String key : prop.stringPropertyNames()) {
+ known.put(key, prop.getProperty(key));
+ }
+ }
+ }
+ } catch (Exception e) {
+ // the mapping is an optimisation of the message, not a requirement
+ }
+ }
+ knownDependencies = known;
Review Comment:
⚠️ **Benign data race — needs a comment explaining the intent**
The lazy initialiser uses `volatile` on the field but no `synchronized` block. This is intentional "safe publication without a lock": two threads can both read `null` and both build a `HashMap` concurrently, but because the field is `volatile`, each thread's final write is globally visible and the maps are identical (same immutable source). The last writer wins, and correctness holds.
However, this pattern is not self-evident. Without a comment, reviewers (and static analysers) will flag this as a data race. Add a short comment:
```suggestion
knownDependencies = known; // benign race: two threads may both build the map; volatile guarantees safe publication
```
##########
dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/SourceValidatorBeanRefsTest.java:
##########
@@ -350,6 +350,43 @@ void aClassInTheWrongPackageIsReported(@TempDir Path dir) throws IOException {
.contains("did you mean org.apache.camel.processor.aggregate.StringAggregationStrategy?");
}
+ @Test
+ void aClassCamelRunDownloadsIsNotReportedAsMissing(@TempDir Path dir) throws IOException {
+ // the Postgres datasource and the Artemis connection factory are not on the CLI classpath, but camel run
+ // resolves them to their Maven dependency (camel-main-known-dependencies.properties) and downloads it, so a
+ // bean of that type runs; the validator must not contradict the runtime
+ List<String> msgs = SourceValidator.validate("r.camel.yaml", """
+ - beans:
+ - name: postgresDS
+ type: "#class:org.postgresql.ds.PGSimpleDataSource"
+ properties:
+ url: "jdbc:postgresql://localhost:5432/postgres"
+ - name: artemisCF
+ type: "#class:org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory"
+ - route:
+ from:
+ uri: "timer:tick?period=1000"
+ steps:
+ - to:
+ uri: "sql:select 1?dataSource=#postgresDS"
+ """, CATALOG, null, dir);
+ assertThat(msgs).isEmpty();
+ assertThat(BeanRefChecks.knownDependency("org.postgresql.ds.PGSimpleDataSource"))
+ .startsWith("org.postgresql:postgresql");
+ assertThat(BeanRefChecks.knownDependency("com.example.NoSuchThing")).isNull();
+ }
+
+ @Test
+ void aClassFromAnUnknownLibrarySaysHowToDeclareTheDependency(@TempDir Path dir) throws IOException {
+ List<String> msgs = SourceValidator.validate("r.camel.yaml", """
+ - beans:
+ - name: pool
+ type: "#class:com.zaxxer.hikari.HikariDataSourceX"
+ """, CATALOG, null, dir);
+ assertThat(msgs).hasSize(1);
+ assertThat(msgs.get(0)).contains("was not found").contains("camel.jbang.dependencies=<groupId>:<artifactId>:<version>");
+ }
+
@Test
void aSiblingClassImportedFromTheWrongPackageIsNamed(@TempDir Path dir) throws IOException {
Review Comment:
💡 **Missing edge-case test: properties files absent from classpath**
`knownDependency()` silently returns a map built from whatever it finds — if neither `camel-main-known-dependencies.properties` nor `camel-component-known-dependencies.properties` is on the classpath the result is an empty map, and the validator falls back to reporting the class as missing (which is the pre-PR behaviour).
That fallback path is not exercised here. A quick test that calls `BeanRefChecks.knownDependency("org.postgresql.ds.PGSimpleDataSource")` in an isolated classloader (or simply checks that the method returns a non-null result when the file is present, and `null` when it isn't) would guard against a future packaging mistake that silently drops the properties file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: camel-jbang - the bean class check honours the known dependencies camel run downloads, and says how to declare an unknown one [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #26574:
URL: https://github.com/apache/camel/pull/26574#issuecomment-5729596714
Merged. The two remaining notes from the review agent, the intent comment on the volatile lazy initialiser and a test for the mapping files being absent from the classpath, are folded into the CAMEL-24810 PR, which changes this class next.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: camel-jbang - the bean class check honours the known dependencies camel run downloads, and says how to declare an unknown one [camel]
Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #26574:
URL: https://github.com/apache/camel/pull/26574#discussion_r4046132238
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/BeanRefChecks.java:
##########
@@ -337,8 +342,51 @@ static int indentOf(String line) {
}
/**
- * A class named with its package that is neither next to the route nor on the CLI classpath: the wrong package
- * (org.apache.camel.support.StringAggregationStrategy) or a missing dependency. Null when the class is fine.
+ * The classes camel run resolves to a Maven dependency and downloads on demand (camel-kamelet-main's
+ * camel-main-known-dependencies.properties, camel-component-known-dependencies.properties and the generated
+ * camel-thirdparty-known-dependencies.properties of CAMEL-24809), so a #class:org.postgresql.ds.PGSimpleDataSource
+ * bean is fine without a dependency declared even though the class is not on the CLI classpath. Matched the way the
+ * runtime matches: the class name, then each enclosing package.
+ */
+ private static volatile Map<String, String> knownDependencies;
Review Comment:
⚠️ **Volatile lazy init — still missing the intent comment**
This is a lock-free "benign data race" idiom: two threads can both read `null`, both build a `HashMap` independently, and the one that writes last wins — both maps contain the same entries so the result is correct. Without a comment, the next reader will either wonder why there is no `synchronized`, or will "helpfully" add one.
Suggested addition:
```suggestion
// Lazy-initialised via a benign data race: two threads may both build the map if they race
// on null; both produce identical maps so the last writer wins without correctness impact.
private static volatile Map<String, String> knownDependencies;
```
##########
dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/SourceValidatorBeanRefsTest.java:
##########
@@ -350,6 +350,44 @@ void aClassInTheWrongPackageIsReported(@TempDir Path dir) throws IOException {
.contains("did you mean org.apache.camel.processor.aggregate.StringAggregationStrategy?");
}
+ @Test
+ void aClassCamelRunDownloadsIsNotReportedAsMissing(@TempDir Path dir) throws IOException {
+ // the Postgres datasource and the Artemis connection factory are not on the CLI classpath, but camel run
+ // resolves them to their Maven dependency (camel-main-known-dependencies.properties) and downloads it, so a
+ // bean of that type runs; the validator must not contradict the runtime
+ List<String> msgs = SourceValidator.validate("r.camel.yaml", """
+ - beans:
+ - name: postgresDS
+ type: "#class:org.postgresql.ds.PGSimpleDataSource"
+ properties:
+ url: "jdbc:postgresql://localhost:5432/postgres"
+ - name: artemisCF
+ type: "#class:org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory"
+ - route:
+ from:
+ uri: "timer:tick?period=1000"
+ steps:
+ - to:
+ uri: "sql:select 1?dataSource=#postgresDS"
+ """, CATALOG, null, dir);
+ assertThat(msgs).isEmpty();
+ assertThat(BeanRefChecks.knownDependency("org.postgresql.ds.PGSimpleDataSource"))
+ .startsWith("org.postgresql:postgresql");
+ assertThat(BeanRefChecks.knownDependency("com.example.NoSuchThing")).isNull();
Review Comment:
💡 **Missing fallback path: properties files absent from classpath**
The first test (`aClassCamelRunDownloadsIsNotReportedAsMissing`) passes because `camel-main-known-dependencies.properties` is on the test classpath. If `knownDependency()` silently gets no resources (empty map), the same YAML would now produce a false-positive error — the very regression this PR fixes. There is no test that covers that path.
The `catch (Exception e)` block swallows all I/O errors by design, so a missing properties file is indistinguishable from an empty one. A test using `BeanRefChecks.knownDependency("org.postgresql.ds.PGSimpleDataSource")` directly would surface a broken classpath setup during the build rather than silently regressing in production.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: camel-jbang - the bean class check honours the known dependencies camel run downloads, and says how to declare an unknown one [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #26574:
URL: https://github.com/apache/camel/pull/26574#issuecomment-5727389145
<!-- ci-tested-modules -->
:test_tube: **CI tested the following changed modules:**
- `dsl/camel-jbang/camel-jbang-core`
---
<details><summary>:microscope: Scalpel shadow comparison — Scalpel: 7 tested, 8 compile-only — current: 6 all tested</summary>
[Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **15 affected modules** (current approach: 6).
<details><summary>:warning: Modules only in Scalpel (9)</summary>
- `camel-jbang-core`
- `camel-jbang-it`
- `camel-jbang-main`
- `camel-jbang-plugin-edit`
- `camel-jbang-plugin-generate`
- `camel-jbang-plugin-kubernetes`
- `camel-jbang-plugin-test`
- `camel-launcher`
- `coverage`
</details>
**Skip-tests mode would test 7 modules** (1 direct + 6 downstream), **skip tests for 8** (generated code, meta-modules)
<details><summary>Modules Scalpel would test (7)</summary>
- `camel-jbang-core`
- `camel-jbang-mcp`
- `camel-jbang-plugin-mcp`
- `camel-jbang-plugin-route-parser`
- `camel-jbang-plugin-tui`
- `camel-jbang-plugin-validate`
- `camel-launcher-container`
</details>
<details><summary>Modules with tests skipped (8)</summary>
- `camel-jbang-it`
- `camel-jbang-main`
- `camel-jbang-plugin-edit`
- `camel-jbang-plugin-generate`
- `camel-jbang-plugin-kubernetes`
- `camel-jbang-plugin-test`
- `camel-launcher`
- `coverage`
</details>
> :information_source: Shadow mode — Scalpel observes but does not affect test execution. [Learn more](https://github.com/maveniverse/scalpel)
</details>
:warning: **Some tests are disabled on GitHub Actions** (`@DisabledIfSystemProperty(named = "ci.env.name")`) and require manual verification:
- `dsl/camel-jbang/camel-jbang-core`: 2 test(s) disabled on GitHub Actions
:bulb: **Manual integration tests recommended:**
> You modified `dsl/camel-jbang/camel-jbang-core`. The related integration tests in `dsl/camel-jbang/camel-jbang-it` are excluded from CI. Consider running them manually:
> ```
> mvn verify -f dsl/camel-jbang/camel-jbang-it -Djbang-it-test
> ```
<details><summary>All tested modules (15 modules, 1m 56s total)</summary>
**Total reactor time:** 1m 56s
| Module | Duration | Status |
| --- | --- | --- |
| Camel :: Launcher | 34.4s | SUCCESS |
| Camel :: JBang :: MCP | 26.2s | SUCCESS |
| Camel :: JBang :: Plugin :: TUI | 24.3s | SUCCESS |
| Camel :: JBang :: Plugin :: Kubernetes | 8.2s | SUCCESS |
| Camel :: JBang :: Plugin :: Testing | 6.8s | SUCCESS |
| Camel :: JBang :: Plugin :: Validate | 4.6s | SUCCESS |
| Camel :: Coverage | 3.0s | SUCCESS |
| Camel :: JBang :: Plugin :: Edit | 2.7s | SUCCESS |
| Camel :: JBang :: Plugin :: MCP | 1.7s | SUCCESS |
| Camel :: JBang :: Plugin :: Generate | 1.1s | SUCCESS |
| Camel :: JBang :: Main | 0.9s | SUCCESS |
| Camel :: JBang :: Integration tests | 0.8s | SUCCESS |
| Camel :: JBang :: Plugin :: Route Parser | 0.7s | SUCCESS |
| Camel :: Launcher :: Container | 0.5s | SUCCESS |
| Camel :: JBang :: Core | n/a | |
**Top 20 slowest modules:**
- `Camel :: Launcher` (34.4s)
- `Camel :: JBang :: MCP` (26.2s)
- `Camel :: JBang :: Plugin :: TUI` (24.3s)
- `Camel :: JBang :: Plugin :: Kubernetes` (8.2s)
- `Camel :: JBang :: Plugin :: Testing` (6.8s)
- `Camel :: JBang :: Plugin :: Validate` (4.6s)
- `Camel :: Coverage` (3.0s)
- `Camel :: JBang :: Plugin :: Edit` (2.7s)
- `Camel :: JBang :: Plugin :: MCP` (1.7s)
- `Camel :: JBang :: Plugin :: Generate` (1.1s)
- `Camel :: JBang :: Main` (0.9s)
- `Camel :: JBang :: Integration tests` (0.8s)
- `Camel :: JBang :: Plugin :: Route Parser` (0.7s)
- `Camel :: Launcher :: Container` (0.5s)
</details>
---
:gear: [View full build and test results](https://github.com/apache/camel/actions/runs/35322520979)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org