gnodet-bot commented on code in PR #30711:
URL: https://github.com/apache/camel/pull/30711#discussion_r4679842820
##########
components/camel-ai/camel-semantic/src/main/java/org/apache/camel/semantic/SemanticEvaluateConsole.java:
##########
@@ -58,16 +61,33 @@ public class SemanticEvaluateConsole extends
AbstractDevConsole {
javaType = "java.lang.Long")
public static final String TIMEOUT = "timeout";
+ private final AtomicInteger active = new AtomicInteger();
private ExecutorService executor;
// A resolver-created console may be called without starting it; only an
explicit stop rejects calls.
private boolean stopped;
+ private boolean tryAcquire() {
+ while (true) {
+ int count = active.get();
+ if (count >= 2) {
+ return false;
+ }
+ if (active.compareAndSet(count, count + 1)) {
+ return true;
+ }
+ }
+ }
+
+ private void release() {
+ active.decrementAndGet();
Review Comment:
💡 **Low — defensive floor guard:** `decrementAndGet()` can produce a
negative value if `release()` is ever called without a matching `tryAcquire()`
(e.g. a future bug, a double-release scenario, or a lifecycle restart with
in-flight tasks from a prior generation). A negative `active` bypasses the
`count >= 2` gate in `tryAcquire()` and allows unlimited concurrent calls.
Consider:
```suggestion
active.updateAndGet(n -> Math.max(0, n - 1));
```
--
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]