luigidemasi commented on code in PR #27494:
URL: https://github.com/apache/camel/pull/27494#discussion_r4216997672
##########
components/camel-ai/camel-semantic/src/main/java/org/apache/camel/language/semantic/SemanticLanguage.java:
##########
@@ -495,7 +545,14 @@ private Object evaluate(Exchange exchange, boolean
asPredicate) {
current = compile(Map.of(name, single));
}
}
+ if (asPredicate) {
+ requireBoolean(current.operations.get(names.get(0)));
+ }
+ startAdapter(current.groups);
Review Comment:
Fixed in
[2ad0b3a75251](https://github.com/apache/camel/commit/2ad0b3a75251700121823e954c49f9f975ef170d).
Managed-adapter activation now happens when a declaration is compiled or
recompiled. Evaluation reuses the compiled result while the selected
declarations are unchanged, so ordinary messages no longer enter
`startAdapter()` or scan managed adapters. Resolving this earlier thread as
requested in [your latest
review](https://github.com/apache/camel/pull/27494#pullrequestreview-5453768092).
_AI-generated by Codex on behalf of @luigidemasi._
##########
components/camel-ai/camel-semantic/src/main/java/org/apache/camel/language/semantic/SemanticLanguage.java:
##########
@@ -65,6 +68,7 @@ public class SemanticLanguage extends LanguageSupport {
public static final String ADAPTER_FACTORY = "semantic-adapter";
public static final String ADAPTER_RESOURCE = FactoryFinder.DEFAULT_PATH +
ADAPTER_FACTORY;
+ private final ThreadLocal<Boolean> validating = new ThreadLocal<>();
Review Comment:
Addressed in
[96e6d465f016](https://github.com/apache/camel/commit/96e6d465f016856fb43c7e95b8e67818cda8112d)
and
[a1c6db3386a0](https://github.com/apache/camel/commit/a1c6db3386a06c540ae89f41c3adcc286000de42).
The registry passes candidate snapshots explicitly and has no ThreadLocal. The
private scope remaining in `SemanticLanguage` is limited to nested Simple
compilation and is suspended around expert resolution and validation callbacks,
then restored in `finally`. Reentrant callback and late-predicate tests cover
successful replacement, rejection and cleanup. This preserves existing Simple
behavior. Resolving following your acceptance in [your latest
review](https://github.com/apache/camel/pull/27494#pullrequestreview-5453768092).
_AI-generated by Codex on behalf of @luigidemasi._
##########
components/camel-ai/camel-semantic/src/main/java/org/apache/camel/semantic/SemanticQuestions.java:
##########
@@ -25,16 +25,30 @@
import java.util.function.Consumer;
import org.apache.camel.CamelContext;
+import org.apache.camel.language.semantic.SemanticLanguage;
import org.apache.camel.spi.Resource;
/** Context-local named questions, replaced atomically per source when a route
resource is reloaded. */
public final class SemanticQuestions {
private static final Object CREATION_LOCK = new Object();
+ private final CamelContext context;
private final Map<String, Map<String, SemanticQuestion>> sources = new
HashMap<>();
private final Map<String, Resource> resources = new HashMap<>();
private volatile Map<String, SemanticQuestion> questions = Map.of();
+ private final ThreadLocal<Map<String, SemanticQuestion>> candidate = new
ThreadLocal<>();
Review Comment:
Fixed in
[96e6d465f016](https://github.com/apache/camel/commit/96e6d465f016856fb43c7e95b8e67818cda8112d):
public `get(name)` and `get(names)` always read published definitions.
Candidate snapshots are passed explicitly to validation; `PendingReplacement`
additionally checks validators registered reentrantly under the registry
monitor. Public reads during callbacks and concurrent reads are covered by
regression tests. Resolving following [your latest
review](https://github.com/apache/camel/pull/27494#pullrequestreview-5453768092).
_AI-generated by Codex on behalf of @luigidemasi._
--
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]