zhfeng commented on a change in pull request #5762: URL: https://github.com/apache/camel/pull/5762#discussion_r660221862
########## File path: components/camel-jms/src/main/java/org/apache/camel/component/jms/StreamMessageInputStream.java ########## @@ -48,6 +48,11 @@ public int read() throws IOException { public int read(byte[] array) throws IOException { try { int num = message.readBytes(array); + if (num < 0) { + //the first 128K(FileUtil.BUFFER_SIZE/128K is used when sending JMS StreamMessage) + //buffer reached, give a chance to see if there is the next 128K buffer + num = message.readBytes(array); + } Review comment: If the payload > 2*128K, this can only read first two chuncks ? ########## File path: components/camel-jms/src/main/java/org/apache/camel/component/jms/StreamMessageInputStream.java ########## @@ -48,6 +48,11 @@ public int read() throws IOException { public int read(byte[] array) throws IOException { try { int num = message.readBytes(array); + if (num < 0) { + //the first 128K(FileUtil.BUFFER_SIZE/128K is used when sending JMS StreamMessage) + //buffer reached, give a chance to see if there is the next 128K buffer + num = message.readBytes(array); + } Review comment: I think it need to remove ```eof = num < 0```. ########## File path: components/camel-jms/src/main/java/org/apache/camel/component/jms/StreamMessageInputStream.java ########## @@ -48,6 +48,11 @@ public int read() throws IOException { public int read(byte[] array) throws IOException { try { int num = message.readBytes(array); + if (num < 0) { + //the first 128K(FileUtil.BUFFER_SIZE/128K is used when sending JMS StreamMessage) + //buffer reached, give a chance to see if there is the next 128K buffer + num = message.readBytes(array); + } Review comment: Well, how can we make sure there is the last chunk ? From the java docs https://docs.oracle.com/javaee/7/api/javax/jms/StreamMessage.html#readBytes-byte:A- ``` To read the field value, readBytes should be successively called until it returns a value less than the length of the read buffer. The value of the bytes in the buffer following the last byte read is undefined. ``` ########## File path: components/camel-jms/src/main/java/org/apache/camel/component/jms/StreamMessageInputStream.java ########## @@ -48,6 +48,11 @@ public int read() throws IOException { public int read(byte[] array) throws IOException { try { int num = message.readBytes(array); + if (num < 0) { + //the first 128K(FileUtil.BUFFER_SIZE/128K is used when sending JMS StreamMessage) + //buffer reached, give a chance to see if there is the next 128K buffer + num = message.readBytes(array); + } Review comment: I suggest to remove the next line ``` eof = num < 0; ``` since we can not to see the eof if the num is -1 because there will be more chunks. ########## File path: components/camel-jms/src/main/java/org/apache/camel/component/jms/StreamMessageInputStream.java ########## @@ -48,6 +48,11 @@ public int read() throws IOException { public int read(byte[] array) throws IOException { try { int num = message.readBytes(array); + if (num < 0) { + //the first 128K(FileUtil.BUFFER_SIZE/128K is used when sending JMS StreamMessage) + //buffer reached, give a chance to see if there is the next 128K buffer + num = message.readBytes(array); + } Review comment: And there might be an indicator to mark the last chunk ? ########## File path: components/camel-jms/src/main/java/org/apache/camel/component/jms/StreamMessageInputStream.java ########## @@ -48,6 +48,11 @@ public int read() throws IOException { public int read(byte[] array) throws IOException { try { int num = message.readBytes(array); + if (num < 0) { + //the first 128K(FileUtil.BUFFER_SIZE/128K is used when sending JMS StreamMessage) + //buffer reached, give a chance to see if there is the next 128K buffer + num = message.readBytes(array); + } Review comment: Ok, I understand now. The last readBytes return -1 means that we have no next chunk to read. Your fix is fine. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org