From 98d06c60f9c4af44ad936a43e829f5f0ec55c2a0 Mon Sep 17 00:00:00 2001 From: James Elliott Date: Tue, 17 Oct 2023 09:10:30 -0500 Subject: [PATCH] Read only bytes of most recent message --- src/main/java/org/deepsymmetry/bcj/Carabiner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/deepsymmetry/bcj/Carabiner.java b/src/main/java/org/deepsymmetry/bcj/Carabiner.java index 5418d47..af42b42 100644 --- a/src/main/java/org/deepsymmetry/bcj/Carabiner.java +++ b/src/main/java/org/deepsymmetry/bcj/Carabiner.java @@ -627,7 +627,7 @@ public void run() { int n = input.read(buffer); if (n > 0 && runForConnectionNumber == connectionNumber.get()) { // We got data, and were not told to shut down while reading. - String response = new String(buffer, StandardCharsets.UTF_8); + String response = new String(buffer, 0, n, StandardCharsets.UTF_8); logger.debug("Received: {}", response); for (String line : response.trim().split("\\R")) { Message message = new Message(line);