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


##########
components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java:
##########
@@ -102,6 +118,11 @@ public void run() {
 
         while (queue != null && isRunAllowed()) {
             final boolean transacted = 
endpoint.getConfiguration().isTransacted();
+            if (transacted && !beginTransacted()) {
+                // the consumer is stopping
+                break;
+            }
+            boolean errorDelay = false;
             // the transacted consumer reads the outcome of the exchange after 
the routing is done, so it releases the
             // exchange itself: a pooled exchange is otherwise reset (and its 
exception cleared) when it is done
             final Exchange exchange = createExchange(!transacted);

Review Comment:
   `beginTransacted()` registers `Thread.currentThread()` into 
`transactedThreads` at line 122, but `createExchange()` at line 129 is 
**outside** the try-finally that calls `endTransacted()`. If `createExchange()` 
throws (e.g., `OutOfMemoryError` or any `RuntimeException` from the exchange 
factory), `endTransacted()` is never called — the thread stays in 
`transactedThreads` forever, and `awaitTransactedExchanges()` waits the full 
shutdown timeout before proceeding.
   
   `createExchange()` rarely throws in practice (it's essentially `new 
DefaultExchange(endpoint)`), so this is low-severity, but it's worth closing.
   
   ```suggestion
               if (transacted && !beginTransacted()) {
                   // the consumer is stopping
                   break;
               }
               boolean errorDelay = false;
               // the transacted consumer reads the outcome of the exchange 
after the routing is done, so it releases the
               // exchange itself: a pooled exchange is otherwise reset (and 
its exception cleared) when it is done
               final Exchange exchange;
               try {
                   exchange = createExchange(!transacted);
               } catch (RuntimeException e) {
                   if (transacted) {
                       endTransacted();
                   }
                   throw e;
               }
   ```



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