gnodet-bot commented on code in PR #27645:
URL: https://github.com/apache/camel/pull/27645#discussion_r4236718036
##########
components/camel-minio/src/main/java/org/apache/camel/component/minio/MinioConsumer.java:
##########
@@ -279,31 +315,81 @@ public void onDone(Exchange exchange) {
});
}
} catch (Exception e) {
+ if (isNoSuchKey(e)) {
+ // deleted (for example by another consumer) after it
was listed
+ LOG.debug("Skipping object {} as it no longer exists",
srcObjectName);
+ inProgress.remove(srcObjectName);
+ skipped++;
+ continue;
+ }
LOG.warn("Error getting MinioObject due: {}",
e.getMessage());
+ // this and the remaining exchanges of the batch are not
processed
+ releaseInProgress(srcObjectName, exchanges);
+ if (ready != null) {
+ routeExchange(ready, routed, total - skipped, false,
0);
+ }
throw e;
}
}
- // add on completion to handle after work when the exchange is done
- exchange.getExchangeExtension().addOnCompletion(new
Synchronization() {
- public void onComplete(Exchange exchange) {
- processCommit(exchange);
+ if (ready != null) {
+ routeExchange(ready, routed++, total - skipped, false,
exchanges.size() + 1);
+ }
+ ready = exchange;
+ }
+ if (ready != null) {
+ if (isBatchAllowed()) {
+ routeExchange(ready, routed, total - skipped,
exchanges.isEmpty(), 0);
+ } else {
+ // not routed as the consumer is stopping
+
inProgress.remove(ready.getIn().getHeader(MinioConstants.OBJECT_NAME,
String.class));
+ for (Synchronization synchronization :
ready.getExchangeExtension().handoverCompletions()) {
+ // closes the object stream when autoCloseBody is enabled
+ synchronization.onFailure(ready);
}
+ }
+ }
+ // the remaining exchanges are not processed as the consumer is
stopping
+ releaseInProgress(null, exchanges);
- public void onFailure(Exchange exchange) {
- processRollback(exchange);
+ return total;
Review Comment:
⚠️ **Bug:** `return total` includes skipped (NoSuchKey) objects in the count
returned to `ScheduledBatchPollingConsumer`. This has two effects:
1. If every listed object was deleted, `processBatch` returns `total > 0` →
`sendEmptyMessageWhenIdle` never fires
2. If skips bring the effective batch below `maxMessagesPerPoll`, `isGreedy`
still triggers an unnecessary immediate re-poll
```suggestion
return total - skipped;
```
--
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]