From 2454c1875ea1d0e59019984b4bb1c7de0c29cf41 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 8 May 2024 05:01:56 +0200 Subject: [PATCH] Do not copy bytes when deserializing ByteBufUtil.getBytes() performs a deep copy of the contents of the buffer. This is completely superfluous, as we can use the underlying nioBuffer() directly. JIRA: CONTROLLER-2115 Change-Id: I0a9f0ec7b22682cd41063db93921c159ba66b082 Signed-off-by: Robert Varga --- .../main/java/io/atomix/storage/journal/JournalSerdes.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/atomix-storage/src/main/java/io/atomix/storage/journal/JournalSerdes.java b/atomix-storage/src/main/java/io/atomix/storage/journal/JournalSerdes.java index ffdc985827..9d6d6ee992 100644 --- a/atomix-storage/src/main/java/io/atomix/storage/journal/JournalSerdes.java +++ b/atomix-storage/src/main/java/io/atomix/storage/journal/JournalSerdes.java @@ -20,7 +20,6 @@ import com.google.common.annotations.Beta; import com.google.common.annotations.VisibleForTesting; import io.atomix.utils.serializer.KryoJournalSerdesBuilder; import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufUtil; import io.netty.buffer.Unpooled; import java.io.IOException; import java.io.InputStream; @@ -127,8 +126,7 @@ public interface JournalSerdes { @Override public T bytesToObject(final ByteBuf buf) { - // FIXME: ByteBufUtil creates a copy -- we do not want to do that! - return deserialize(ByteBufUtil.getBytes(buf)); + return deserialize(buf.nioBuffer()); } }; } -- 2.36.6