davsclaus commented on code in PR #25740:
URL: https://github.com/apache/camel/pull/25740#discussion_r3860108845
##########
components/camel-ibm/camel-ibm-cos/src/main/java/org/apache/camel/component/ibm/cos/IBMCOSConsumer.java:
##########
@@ -160,7 +160,7 @@ protected Queue<Exchange>
createExchanges(List<S3ObjectSummary> s3ObjectSummarie
}
if (getEndpoint().getInProgressRepository() != null
- &&
getEndpoint().getInProgressRepository().contains(s3ObjectSummary.getKey())) {
+ &&
!getEndpoint().getInProgressRepository().add(s3ObjectSummary.getKey())) {
Review Comment:
If `getCosClient().getObject(...)` or `createExchange(...)` throws a few
lines below (after this `add()` succeeds), `s3ObjectSummary.getKey()` is now
permanently marked in-progress with no way back: no `Synchronization` gets
attached to that exchange since it was never created, so neither
`processCommit` nor `processRollback` ever fires to remove it. The object
becomes silently unconsumable until FIFO cache eviction or a consumer restart.
`AWS2S3Consumer.createExchanges(List<S3Object>)` (the reference this PR says
it mirrors) guards against exactly this: it wraps the whole batch loop in
try/catch and removes the in-progress key for every exchange already added to
the batch before rethrowing on any exception. Worth porting the same safety net
here, e.g. wrapping the `getCosClient().getObject(...)` + `createExchange(...)`
calls below in:
```java
try {
S3Object s3Object = getCosClient().getObject(
new GetObjectRequest(s3ObjectSummary.getBucketName(),
s3ObjectSummary.getKey()));
Exchange exchange = createExchange(s3Object, s3ObjectSummary.getKey());
exchanges.add(exchange);
} catch (Exception e) {
removeInProgress(s3ObjectSummary.getKey());
throw e;
}
```
(Not posting this as a one-click suggestion since there's more than one
valid shape for the try/catch — e.g. rethrow immediately vs. continue the batch
like AWS2S3's outer try/catch does — and that's a judgment call for the author.)
--
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]