davsclaus opened a new pull request, #26036: URL: https://github.com/apache/camel/pull/26036
## Description [CAMEL-24585](https://issues.apache.org/jira/browse/CAMEL-24585) `CamelCatalog.validateLanguageExpression(cl, "simple", "${jsonpath($.foo)}")` fails with: ``` Cannot invoke "org.apache.camel.TypeConverter.convertTo(java.lang.Class, Object)" because the return value of "org.apache.camel.CamelContext.getTypeConverter()" is null ``` This regressed for simple expressions that embed a delegating language function (`${jsonpath(...)}`, `${jq(...)}`, `${xpath(...)}`). Plain simple expressions (`${header.foo}`, `${bodyAs(String)}`) are unaffected. ## Root cause The catalog validates simple expressions by parsing them against a deliberately **uninitialized** `SimpleCamelContext` (no type converter). When the simple parser encounters a delegating function it eagerly initializes the target language (via `ExpressionBuilder.languageExpression`), which resolves the target language's default option values through `LanguageSupport.property()`. That method unconditionally called `camelContext.getTypeConverter().convertTo(type, value)` — even for values that are already the correct type (e.g. the `suppressExceptions` boolean default) — and `getTypeConverter()` is `null` on the bare tooling context, producing an NPE. ## Fix Guard `LanguageSupport.property()` against a null type converter: when no converter is available (i.e. a bare `CamelContext` used only for tooling/validation), return the value as-is, mirroring the existing `camelContext == null` branch. In a fully initialized runtime context the type converter is always present, so runtime behavior is unchanged. ## Testing - Added a regression test `CamelCatalogTest#testValidateSimpleJSonPathFunction` validating `${jsonpath($.foo)}` (expression and predicate) succeeds. - Reproduced the original NPE on 4.22.0 and confirmed the fix resolves it. - Full reactor build (`mvn clean install -Dquickly`) passes. --- _Claude Code on behalf of davsclaus_ -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
