This is an automated email from the ASF dual-hosted git repository. oalsafi pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 2fc0719 CAMEL-15327: Wrap FileInputStream with BufferedInputStream and check if InputStream supports mark/reset operations (#4034) 2fc0719 is described below commit 2fc0719b9ed954d151b075a4f7185f92d534b37b Author: Omar Al-Safi <omars...@gmail.com> AuthorDate: Wed Jul 22 16:11:25 2020 +0200 CAMEL-15327: Wrap FileInputStream with BufferedInputStream and check if InputStream supports mark/reset operations (#4034) --- .../camel/component/azure/storage/blob/BlobStreamAndLength.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/BlobStreamAndLength.java b/components/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/BlobStreamAndLength.java index 1a6bf13..b4ac124 100644 --- a/components/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/BlobStreamAndLength.java +++ b/components/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/BlobStreamAndLength.java @@ -16,6 +16,7 @@ */ package org.apache.camel.component.azure.storage.blob; +import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; @@ -46,10 +47,14 @@ public final class BlobStreamAndLength { } if (body instanceof InputStream) { + // Note: InputStream has to support mark/reset operations + if (!((InputStream) body).markSupported()) { + throw new IllegalArgumentException("InputStream of body exchange does not support mark/rest operations."); + } return new BlobStreamAndLength((InputStream) body, BlobUtils.getInputStreamLength((InputStream) body)); } if (body instanceof File) { - return new BlobStreamAndLength(new FileInputStream((File) body), ((File) body).length()); + return new BlobStreamAndLength(new BufferedInputStream(new FileInputStream((File) body)), ((File) body).length()); } if (body instanceof byte[]) { return new BlobStreamAndLength(new ByteArrayInputStream((byte[]) body), ((byte[]) body).length);