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

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


The following commit(s) were added to refs/heads/main by this push:
     new 17bbaac  Fix incorrect read from InputStream (#5705)
17bbaac is described below

commit 17bbaac3e4e3380958c81d64217a100bfc986a82
Author: gordeevnm <[email protected]>
AuthorDate: Fri Jun 18 22:04:12 2021 +0300

    Fix incorrect read from InputStream (#5705)
    
    I didn't test that fix 🙃, but I assume it would work correctly
---
 .../main/java/org/apache/camel/component/http/HttpProducer.java   | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git 
a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
 
b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
index 20d794f..7df069b 100644
--- 
a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
+++ 
b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
@@ -513,7 +513,13 @@ public class HttpProducer extends DefaultProducer {
                     if (len > 0 && len <= max) {
                         int i = (int) len;
                         byte[] arr = new byte[i];
-                        is.read(arr, 0, i);
+                        int read = 0;
+                        int offset = 0;
+                        int remain = i;
+                        while ((read = is.read(arr, offset, remain)) > 0 && 
remain > 0) {
+                            offset += read;
+                            remain -= read;
+                        }
                         IOHelper.close(is);
                         return arr;
                     }

Reply via email to