“ConnectionPoolTimeoutException” when iterating objects in S3

前端 未结 2 1417
别那么骄傲
别那么骄傲 2021-02-05 14:21

I\'ve been working for some time with aws java API with not so many problems. Currently I\'m using the library 1.5.2 version.

When I\'m iterating the objects inside a f

相关标签:
2条回答
  • 2021-02-05 14:37

    Check if HttpResponseHandler is closing connections from the pool. AmazonHttpClient has the paramter 'leaveHttpConnectionOpen' which indicates that the connection should be closed or not.

    0 讨论(0)
  • 2021-02-05 14:41

    I've found that S3Object opens a connection for each object. That are not liberated even if the object is garbage collected so it is needed to execute object.close(), in order to liberate the connection to the pool.

    So the corrected code would be:

     for (S3ObjectSummary objectSummary : current.getObjectSummaries()) {        
            S3Object object = s3.getObject(new GetObjectRequest(bucketName, objectSummary.getKey()));             
            System.out.println(object.getKey());
            object.close();
        }
    
    0 讨论(0)
提交回复
热议问题