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 2024/06/07 04:38:53 UTC
(camel) branch camel-4.4.x updated: CAMEL-20841 Fixes DS expressions not able to be evalated after being removed from mapperCache (#14411)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.4.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.4.x by this push:
new b41ee31adbf CAMEL-20841 Fixes DS expressions not able to be evalated after being removed from mapperCache (#14411)
b41ee31adbf is described below
commit b41ee31adbf6b0bb33b1f328c7d312058b72e5b0
Author: Rob Ratcliffe <rl...@tcliffe.dev>
AuthorDate: Fri Jun 7 00:36:19 2024 -0400
CAMEL-20841 Fixes DS expressions not able to be evalated after being removed from mapperCache (#14411)
* change to initialize expression if not found
* switch to only use computeIfMiss
* add comment back
---
.../camel/language/datasonnet/DatasonnetExpression.java | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/components/camel-datasonnet/src/main/java/org/apache/camel/language/datasonnet/DatasonnetExpression.java b/components/camel-datasonnet/src/main/java/org/apache/camel/language/datasonnet/DatasonnetExpression.java
index 86bb0b244ff..3ead8d5574b 100644
--- a/components/camel-datasonnet/src/main/java/org/apache/camel/language/datasonnet/DatasonnetExpression.java
+++ b/components/camel-datasonnet/src/main/java/org/apache/camel/language/datasonnet/DatasonnetExpression.java
@@ -133,9 +133,20 @@ public class DatasonnetExpression extends ExpressionAdapter implements Expressio
}
}
- // the mapper is pre initialized
- Mapper mapper = language.lookup(expression)
- .orElseThrow(() -> new IllegalStateException("Datasonnet expression not initialized"));
+ // the mapper is pre initialized but can become empty
+ Mapper mapper = language.computeIfMiss(expression, () -> {
+ MapperBuilder builder = new MapperBuilder(expression)
+ .withInputNames("body")
+ .withImports(resolveImports(language))
+ .withLibrary(CML.getInstance())
+ .withDefaultOutput(MediaTypes.APPLICATION_JAVA);
+
+ Set<Library> additionalLibraries = exchange.getContext().getRegistry().findByType(com.datasonnet.spi.Library.class);
+ for (Library lib : additionalLibraries) {
+ builder = builder.withLibrary(lib);
+ }
+ return builder.build();
+ });
MediaType outMT = outputMediaType;
if (outMT == null) {