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


##########
core/camel-api/src/main/java/org/apache/camel/spi/AsyncProcessorAwaitManager.java:
##########
@@ -176,6 +179,14 @@ default String getNodeSource() {
      * Though if it appears as the exchange is <i>stuck</i>, then this method 
can remedy this, by forcing the latch to
      * count-down so the blocked thread can continue. An exception is set on 
the exchange which allows Camel's error
      * handler to deal with this malfunctioned exchange.
+     * <p>
+     * When more than one thread waits for the exchange, only the thread whose
+     * {@link #process(AsyncProcessor, Exchange)} call started last is 
released. This is a nested wait: a thread waits

Review Comment:
   💬 **Still open:** The sentence "This is a nested wait: a thread waits for 
the exchange while the exchange goes on, on another thread, through a step that 
waits for it too (such as `ProducerTemplate.send(uri, exchange)`)." runs 37 
words. Split suggestion from the earlier review was not applied:
   
   ```suggestion
        * <p>
        * When more than one thread waits for the exchange, only the thread 
whose
        * {@link #process(AsyncProcessor, Exchange)} call started last is 
released. This is a nested wait:
        * one thread waits for the exchange while, on another thread, the 
exchange enters a step that also
        * waits for it (such as {@code ProducerTemplate.send(uri, exchange)}). 
The released inner thread
        * proceeds with the failed exchange to the end of its route, and the 
callback then releases the
        * outer thread. An interrupt never releases both threads of a nested 
wait.
   ```



##########
core/camel-api/src/main/java/org/apache/camel/ExchangeExtension.java:
##########
@@ -143,6 +143,13 @@ default void setSharedUnitOfWork(@Nullable UnitOfWork 
unitOfWork) {
      */
     void setInterrupted(boolean interrupted);
 
+    /**
+     * Used by the {@link org.apache.camel.spi.AsyncProcessorAwaitManager} 
each time a thread calls it to wait for this
+     * exchange: returns a number one higher than the previous call for this 
exchange, so the manager knows which of the
+     * threads that wait for the exchange called it last. This is used 
internally by Camel.
+     */
+    long nextAwaitOrder();

Review Comment:
   ⚠️ **Still open + 🔧 New:** Two issues with `nextAwaitOrder()`:
   
   1. **Missing `@since 4.24`** — Camel convention requires this for new public 
methods on `camel-api` interfaces.
   2. **Sequential-access assumption undocumented** — "each time a thread calls 
it" reads as concurrent-safe. The safety guarantee (outer `process()` takes its 
order before the inner `process()` starts, because the inner starts from within 
the outer's processing, so calls are always sequential for the same exchange) 
needs a Javadoc note — otherwise an `ExchangeExtension` implementer reading 
this may either over-engineer with `AtomicLong` or miss the constraint and 
produce a data race.
   
   ```suggestion
       /**
        * Used by the {@link org.apache.camel.spi.AsyncProcessorAwaitManager} 
each time a thread calls it to wait for this
        * exchange: returns a number one higher than the previous call for this 
exchange, so the manager knows which of the
        * threads that wait for the exchange called it last. Calls for the same 
exchange are sequential: an inner
        * {@code process()} call starts from within the processing of the outer 
one, so a plain (non-atomic) counter
        * is safe. This is used internally by Camel.
        *
        * @since 4.24
        */
       long nextAwaitOrder();
   ```



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