camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrea Cosentino (JIRA)" <>
Subject [jira] [Commented] (CAMEL-11698) S3 Consumer does not close S3 Object Input Streams and this causes HTTP connection leaks
Date Wed, 23 Aug 2017 12:18:01 GMT


Andrea Cosentino commented on CAMEL-11698:

By the way you're welcome to work on a PR or a patch for improving this.

> S3 Consumer does not close S3 Object Input Streams and this causes HTTP connection leaks
> ----------------------------------------------------------------------------------------
>                 Key: CAMEL-11698
>                 URL:
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-aws
>    Affects Versions: 2.14.3, 2.19.2
>            Reporter: MykhailoVlakh
>            Assignee: Andrea Cosentino
>         Attachments:
> It looks like S3Consumer does nothing to prevent HTTP Connection leaks that can easily
happen if some exception is thrown while it is generates a batch of exchanges and sends them
for processing. Also we can lose HTTP Connections if our route does not close S3 Object Input
Streams which can easily happen.
> Due to this issue s3 consumer may works some time and then start failing with the following
> {code}
> com.amazonaws.AmazonClientException: Unable to execute HTTP request: Timeout waiting
for connection from pool
> 	at com.amazonaws.http.AmazonHttpClient.executeHelper(
> 	at com.amazonaws.http.AmazonHttpClient.execute(
> 	at
> 	at
> 	at$201(
> 	at$S3DirectImpl.getObject(
> 	at
> 	at
> 	at
> 	at
> 	at
> 	at
> 	at org.apache.camel.impl.ScheduledPollConsumer.doRun(
> 	at
> 	at java.util.concurrent.Executors$
> 	at java.util.concurrent.FutureTask.runAndReset(
> 	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(
> 	at java.util.concurrent.ScheduledThreadPoolExecutor$
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(
> 	at java.util.concurrent.ThreadPoolExecutor$
> 	at
> {code}
> I found 3 week points in the way S3Consumer is implemented:
> 1. It does not handle exceptions in the poll() method where it reads a single s3 object
which means that s3 object stream can be left opened forever in case of some fault;
> 2. It also does not handle exceptions in the createExchanges method where it populates
a list of exchanges based on the list of s3 objects available in the bucket. If for example
we want to consumer 10 files in a pool and getObject call for the file 10 failed due to whatever
reason steams for 9 objects that are already opened will be lost;
> 3. In order to make sure that we always close all the streams and to not force user to
do this all the time the implementation of the processBatch method should be also improved
to close all the opened streams in the finally block.
> In order to resolve issues 2 and 3 in my current project (the issue 1 is not affecting
me because I do not use that feature) I implemented a custom extension of the native S3Consumer
that I want to share with you. It will give you the idea of the required changes that need
to be applied to fix these issues. I hope it will be useful.

This message was sent by Atlassian JIRA

View raw message