You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/12/30 09:11:23 UTC
[camel] 03/05: camel-aws-lambda: Close FileInputStreams in
LambdaProducer#createFunction because
com.amazonaws.util.IOUtils#toByteArray requires the client to close the
InputStream.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit c95d049f74ed691f97585fb6a838af625ecfec40
Author: Pascal Schumacher <pa...@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 3058764..2380441 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));