From 421fda674e17850329e7c0b31144756abb3bde76 Mon Sep 17 00:00:00 2001 From: Yevgeny Griz Date: Wed, 7 Aug 2024 11:24:03 +0300 Subject: [PATCH] read only specified size of chunked data --- .../ca/uhn/hl7v2/hoh/encoder/AbstractHl7OverHttpDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hapi-hl7overhttp/src/main/java/ca/uhn/hl7v2/hoh/encoder/AbstractHl7OverHttpDecoder.java b/hapi-hl7overhttp/src/main/java/ca/uhn/hl7v2/hoh/encoder/AbstractHl7OverHttpDecoder.java index 0878b8051..5c188f3f9 100644 --- a/hapi-hl7overhttp/src/main/java/ca/uhn/hl7v2/hoh/encoder/AbstractHl7OverHttpDecoder.java +++ b/hapi-hl7overhttp/src/main/java/ca/uhn/hl7v2/hoh/encoder/AbstractHl7OverHttpDecoder.java @@ -273,7 +273,7 @@ private byte[] readBytesChunked(InputStream theInputStream) throws DecodeExcepti int totalRead = 0; myLastStartedReading = System.currentTimeMillis(); do { - int nextRead = Math.min(nextSizeInt, byteBuffer.length); + int nextRead = Math.min(nextSizeInt - totalRead, byteBuffer.length); int bytesRead = theInputStream.read(byteBuffer, 0, nextRead); if (bytesRead == -1) { ourLog.debug("Exception in readBytesChunked(InputStream): Reached EOF. Buffer has {} bytes", bos.size());