This is an automated email from the ASF dual-hosted git repository.

pascalschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 6287b6d1c60f0cc281fbdd642788a09a4443400e
Author: Pascal Schumacher <pascalschumac...@gmx.net>
AuthorDate: Sun Dec 29 16:35:18 2019 +0100

    camel-aws-lambda: Close FileInputStreams in LambdaProducer#createFunction 
because com.amazonaws.util.IOUtils#toByteArray requires the client to close the 
InputStream.
---
 .../org/apache/camel/component/aws/lambda/LambdaProducer.java  | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git 
a/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaProducer.java
 
b/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaProducer.java
index d71cd9a..ed90cf1 100644
--- 
a/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaProducer.java
+++ 
b/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaProducer.java
@@ -202,8 +202,9 @@ public class LambdaProducer extends DefaultProducer {
             if 
(ObjectHelper.isNotEmpty(exchange.getIn().getHeader(LambdaConstants.ZIP_FILE))) 
{
                 String zipFile = 
exchange.getIn().getHeader(LambdaConstants.ZIP_FILE, String.class);
                 File fileLocalPath = new File(zipFile);
-                FileInputStream inputStream = new 
FileInputStream(fileLocalPath);
-                
functionCode.withZipFile(ByteBuffer.wrap(IOUtils.toByteArray(inputStream)));
+                try (FileInputStream inputStream = new 
FileInputStream(fileLocalPath)) {
+                    
functionCode.withZipFile(ByteBuffer.wrap(IOUtils.toByteArray(inputStream)));
+                }
             }
             if (ObjectHelper.isNotEmpty(exchange.getIn().getBody())) {
                 
functionCode.withZipFile(exchange.getIn().getBody(ByteBuffer.class));
@@ -337,8 +338,9 @@ public class LambdaProducer extends DefaultProducer {
             if 
(ObjectHelper.isNotEmpty(exchange.getIn().getHeader(LambdaConstants.ZIP_FILE))) 
{
                 String zipFile = 
exchange.getIn().getHeader(LambdaConstants.ZIP_FILE, String.class);
                 File fileLocalPath = new File(zipFile);
-                FileInputStream inputStream = new 
FileInputStream(fileLocalPath);
-                
functionCode.withZipFile(ByteBuffer.wrap(IOUtils.toByteArray(inputStream)));
+                try (FileInputStream inputStream = new 
FileInputStream(fileLocalPath)) {
+                    
functionCode.withZipFile(ByteBuffer.wrap(IOUtils.toByteArray(inputStream)));
+                }
             }
             if (ObjectHelper.isNotEmpty(exchange.getIn().getBody())) {
                 
functionCode.withZipFile(exchange.getIn().getBody(ByteBuffer.class));

Reply via email to