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


##########
components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/stream/AWS2S3StreamUploadProducer.java:
##########
@@ -71,9 +72,21 @@ public class AWS2S3StreamUploadProducer extends 
DefaultProducer {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(AWS2S3StreamUploadProducer.class);
     private static final String TIMEOUT_CHECKER_EXECUTOR_NAME = 
"S3_Streaming_Upload_Timeout_Checker";
+    // the number of timestamp windows whose completed uploads are counted
+    private static final int MAX_COUNTED_WINDOWS = 10000;
     private AtomicInteger part = new AtomicInteger();
     private UploadState uploadAggregate = null;
     private final Map<Long, UploadState> timestampBasedUploads = new 
ConcurrentHashMap<>();
+    // The uploads completed for each timestamp window, guarded by the lock. A 
window is uploaded again when it gets
+    // more messages after its upload was completed (batchMessageNumber, 
batchSize or streamingUploadTimeout); the new
+    // object gets a name of its own, as an object with the name of the first 
one would replace it. Only the windows
+    // used last are counted, so a long-running producer does not keep every 
window it has seen.
+    private final Map<Long, Integer> completedUploadsByWindow = new 
LinkedHashMap<>(16, 0.75f, true) {

Review Comment:
   ⚠️ **Maintenance note:** `accessOrder=true` (the third constructor argument) 
makes every `get()` a structural modification of the map. The existing comment 
notes it’s “guarded by the lock”, which keeps the current `merge()` and 
`getOrDefault()` calls safe. Consider adding a warning comment here so future 
maintainers don’t inadvertently call `get()` inside an iteration loop—it would 
throw `ConcurrentModificationException`.



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