davsclaus commented on code in PR #27672:
URL: https://github.com/apache/camel/pull/27672#discussion_r4240436819


##########
components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Consumer.java:
##########
@@ -361,6 +376,17 @@ public String toString() {
             AsyncCallback cb = defaultConsumerCallback(exchange, true);
             getAsyncProcessor().process(exchange, cb);
         }
+        // the remaining exchanges are not processed as the consumer is 
stopping: a later poll must consume their
+        // objects again, and with includeBody=false their bodies are the 
object streams, which nothing else closes
+        for (Object exchange : exchanges) {
+            String key = ((Exchange) 
exchange).getProperty(AWS2S3Constants.KEY, String.class);
+            if (key != null) {
+                getEndpoint().getInProgressRepository().remove(key);
+            }
+            if (((Exchange) exchange).getIn().getBody() instanceof Closeable 
body) {

Review Comment:
   Nit: with `includeBody=false` + `ignoreBody=true` the `ResponseInputStream` 
isn't the body, so it's not closed here, and the autoclose on completion never 
runs for an exchange that isn't routed. Odd combination, minor leak.



##########
components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Consumer.java:
##########
@@ -361,6 +376,17 @@ public String toString() {
             AsyncCallback cb = defaultConsumerCallback(exchange, true);
             getAsyncProcessor().process(exchange, cb);
         }
+        // the remaining exchanges are not processed as the consumer is 
stopping: a later poll must consume their
+        // objects again, and with includeBody=false their bodies are the 
object streams, which nothing else closes
+        for (Object exchange : exchanges) {
+            String key = ((Exchange) 
exchange).getProperty(AWS2S3Constants.KEY, String.class);
+            if (key != null) {
+                getEndpoint().getInProgressRepository().remove(key);
+            }
+            if (((Exchange) exchange).getIn().getBody() instanceof Closeable 
body) {
+                IOHelper.close(body);

Review Comment:
   Nit: these exchanges are never routed, so they're not released back to the 
exchange factory (matters with a pooled factory). 
`GenericFileConsumer.removeExcessiveInProgressFiles` calls 
`releaseExchange(exchange, true)` here.



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