You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2026/09/13 13:54:45 UTC
(camel) 01/01: CAMEL-24698: camel-catalog - the Simple bean function validates without a registry
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch pr/CAMEL-24698-catalog-bean-function
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 7c3476cb20ce2ddb664aff76d8e84a07e67a432e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Sep 13 15:09:08 2026 +0200
CAMEL-24698: camel-catalog - the Simple bean function validates without a registry
Squash of the 1 commits on fix/CAMEL-24698-catalog-bean-function (the run-by-run history is on bench/after-run).
camel-core-catalog - validating a simple expression must not report a ${bean:...} lookup as an error
Co-Authored-By: Claude Fable 5.1 <no...@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bp3538HRBPMQkb5ta9xRaj
---
.../test/java/org/apache/camel/catalog/CamelCatalogTest.java | 12 ++++++++++++
.../org/apache/camel/catalog/impl/AbstractCamelCatalog.java | 7 +++++++
2 files changed, 19 insertions(+)
diff --git a/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java b/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
index 06f7114c03f4..e3a682bc4068 100644
--- a/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
+++ b/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
@@ -1233,6 +1233,18 @@ public class CamelCatalogTest {
assertEquals(22, result.getIndex());
}
+ @Test
+ public void testSimpleBeanFunctionIsNotALookupAtValidationTime() {
+ // the bean is only known at runtime; the validator has no registry and must not report it as missing
+ LanguageValidationResult result = catalog.validateLanguageExpression(null, "simple", "${bean:myBean.count}");
+ assertTrue(result.isSuccess(), result.getError());
+ result = catalog.validateLanguagePredicate(null, "simple", "${bean:myBean?method=isReady} == true");
+ assertTrue(result.isSuccess(), result.getError());
+ // a real syntax error next to it is still reported
+ result = catalog.validateLanguageExpression(null, "simple", "${bean:myBean.count");
+ assertFalse(result.isSuccess());
+ }
+
@Test
public void testPredicatePlaceholder() {
LanguageValidationResult result = catalog.validateLanguagePredicate(null, "simple", "${body} contains '{{danger}}'");
diff --git a/core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/AbstractCamelCatalog.java b/core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/AbstractCamelCatalog.java
index a03a189e4553..a92b4c9d9590 100644
--- a/core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/AbstractCamelCatalog.java
+++ b/core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/AbstractCamelCatalog.java
@@ -1493,6 +1493,13 @@ public abstract class AbstractCamelCatalog {
cause = e;
}
+ if (cause != null && cause.getMessage() != null
+ && cause.getMessage().contains("No bean could be found in the registry")) {
+ // ${bean:name...} looks the bean up when the expression is created; there is no registry here, so
+ // the lookup cannot say anything about the syntax, which is what this validates (CAMEL-24698)
+ cause = null;
+ }
+
if (cause != null) {
// reverse the dummy placeholders back to {{XXX}}