From 5f4f62620687f6d34bdd75ba659fb58350661169 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Sat, 4 Jul 2020 08:55:06 +0200 Subject: [PATCH] Fix large message writing --- src/main/java/com/jenkov/nioserver/Message.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/jenkov/nioserver/Message.java b/src/main/java/com/jenkov/nioserver/Message.java index 4e1cb3d..2107c37 100644 --- a/src/main/java/com/jenkov/nioserver/Message.java +++ b/src/main/java/com/jenkov/nioserver/Message.java @@ -67,7 +67,7 @@ public class Message { while (this.length + remaining > capacity) if (!this.messageBuffer.expandMessage(this)) return -1; - int bytesToCopy = Math.min(remaining, capacity - length); + int bytesToCopy = Math.min(remaining, capacity - this.length); System.arraycopy(byteArray, offset, sharedArray, this.offset + this.length, bytesToCopy); this.length += bytesToCopy; return bytesToCopy;