gnodet-bot commented on code in PR #26753:
URL: https://github.com/apache/camel/pull/26753#discussion_r4075639577


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/ExpressionEvaluator.java:
##########
@@ -113,16 +119,54 @@ private static void evaluateInProcess(
     }
 
     private static void evaluateLocally(
-            String lang, String expression, String body, boolean predicate, 
JsonObject result) {
+            ToolContext ctx, String lang, String expression, String body, 
boolean predicate, JsonObject result) {
+        ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+        try {
+            String gav = languageArtifact(ctx, lang);
+            // the languages of this process (simple, constant, header, ...) 
need no class loader of their own
+            ClassLoader known = gav != null ? DOWNLOADED.get(gav) : null;
+            if (evaluateWith(known, lang, expression, body, predicate, 
result)) {
+                syntaxCheck(ctx, known, lang, expression, predicate, result);
+                return;

Review Comment:
   🔍 **`"downloaded"` missing on cache hit.**
   
   When the same language is evaluated a second time, `DOWNLOADED.get(gav)` 
returns the cached `ClassLoader` (`known != null`), `evaluateWith(known, ...)` 
succeeds, and the method returns at this `return` — never reaching 
`result.put("downloaded", gav)` below. The second call's response lacks 
`"downloaded"` entirely, while the first had it. An agent checking for 
`"downloaded"` to understand whether a component was fetched gets an 
inconsistent picture across calls.
   
   ```suggestion
               ClassLoader known = gav != null ? DOWNLOADED.get(gav) : null;
               if (evaluateWith(known, lang, expression, body, predicate, 
result)) {
                   if (known != null) {
                       result.put("downloaded", gav); // previously cached; 
still report it
                   }
                   syntaxCheck(ctx, known, lang, expression, predicate, result);
   ```



-- 
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]

Reply via email to