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


##########
core/camel-core-processor/src/main/java/org/apache/camel/processor/aggregate/AggregateProcessor.java:
##########
@@ -1973,6 +1967,46 @@ public int forceDiscardingOfAllGroups() {
         return total;
     }
 
+    /**
+     * Completes the group and sends the aggregated exchange. Must be called 
while holding the lock.
+     *
+     * @return <tt>false</tt> if another Camel instance completed the group 
first (optimistic locking)

Review Comment:
   **Nit: deprecated HTML tag + inaccurate wording.** `<tt>` has been 
deprecated since HTML 4 — Javadoc should use `{@code false}`. Also, the 
`@return` wording says "completed" but this method completes; the stolen-group 
case happens because *another node already completed it*, so the wording is 
fine for `forceCompletion`. Fixing the `<tt>` tag:
   
   ```suggestion
        * @return {@code false} if another Camel instance has already completed 
the group (optimistic locking)
   ```



##########
core/camel-core-processor/src/main/java/org/apache/camel/processor/aggregate/AggregateProcessor.java:
##########
@@ -1973,6 +1967,46 @@ public int forceDiscardingOfAllGroups() {
         return total;
     }
 
+    /**
+     * Completes the group and sends the aggregated exchange. Must be called 
while holding the lock.
+     *
+     * @return <tt>false</tt> if another Camel instance completed the group 
first (optimistic locking)
+     */
+    private boolean forceCompletion(String key, Exchange exchange) {
+        try {
+            Exchange answer = onCompletion(key, exchange, exchange, false, 
false);
+            if (answer != null) {
+                onSubmitCompletion(key, answer);
+            }
+            return true;
+        } catch 
(OptimisticLockingAggregationRepository.OptimisticLockingException e) {
+            LOG.debug("Another Camel instance has already completed the group 
with correlation key: {}", key);
+            return false;
+        }
+    }
+
+    /**
+     * Discards the group. Must be called while holding the lock.
+     *
+     * @return <tt>false</tt> if another Camel instance completed the group 
first (optimistic locking)

Review Comment:
   **Nit: deprecated HTML tag + misleading wording.** `<tt>` → `{@code false}`. 
More critically, `forceDiscarding` is about *discarding* a group, yet the 
`@return` says "completed the group first" — a reader would wonder why 
completing and discarding collide. The other node may have completed *or* 
discarded it; what matters is that the `remove()` call in `onCompletion` 
rejected it with `OptimisticLockingException`. A more accurate description:
   
   ```suggestion
        * @return {@code false} if another Camel instance has already removed 
the group from the repository (optimistic locking)
   ```



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