ammachado commented on code in PR #30470:
URL: https://github.com/apache/camel/pull/30470#discussion_r4643209859


##########
components/camel-file/src/main/java/org/apache/camel/component/file/GenericFilePollingConsumer.java:
##########
@@ -233,9 +240,39 @@ public void process(Exchange exchange) throws Exception {
             slot[0] = isCopy() || exchange instanceof PooledExchange ? 
prepareCopy(exchange, true) : exchange;
             return;
         }
+        if (slot != null) {
+            // the receive call on this thread already returns another 
exchange, and nothing takes this one from the
+            // queue, which would keep its file in the in-progress repository, 
skipped by every later poll (CAMEL-27264)
+            rollbackNotReturned(exchange, slot[0]);
+            return;
+        }
         super.process(exchange);
     }
 
+    /**
+     * Completes an exchange that the receive call cannot return as failed, so 
a polled file is rolled back, and removed
+     * from the in-progress repository to be polled again.
+     */

Review Comment:
   Done in 76216449a8a2: added the `@param` tags (the Javadoc was also 
reworded, as the method now aborts instead of rolling back).
   
   _Claude Code on behalf of ammachado_



##########
components/camel-file/src/main/java/org/apache/camel/component/file/GenericFilePollingConsumer.java:
##########
@@ -233,9 +240,39 @@ public void process(Exchange exchange) throws Exception {
             slot[0] = isCopy() || exchange instanceof PooledExchange ? 
prepareCopy(exchange, true) : exchange;
             return;
         }
+        if (slot != null) {
+            // the receive call on this thread already returns another 
exchange, and nothing takes this one from the
+            // queue, which would keep its file in the in-progress repository, 
skipped by every later poll (CAMEL-27264)
+            rollbackNotReturned(exchange, slot[0]);
+            return;
+        }
         super.process(exchange);
     }
 
+    /**
+     * Completes an exchange that the receive call cannot return as failed, so 
a polled file is rolled back, and removed
+     * from the in-progress repository to be polled again.
+     */
+    private static void rollbackNotReturned(Exchange exchange, Exchange 
returned) {
+        if (exchange.getException() == null) {
+            exchange.setException(new CamelExchangeException(
+                    "Rolled back as the receive call already returns exchange: 
" + returned.getExchangeId(), exchange));
+        } else {
+            LOG.warn(
+                    "Cannot return exchange: {} as the receive call already 
returns exchange: {}. Its exception is ignored: {}",
+                    exchange.getExchangeId(), returned.getExchangeId(), 
exchange.getException().getMessage());

Review Comment:
   Done in 76216449a8a2: the message now reads "Its exception is not returned 
to the caller".
   
   _Claude Code on behalf of ammachado_



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