From 22b0c705000b89f4718e79fcef8aa4b209a12aba Mon Sep 17 00:00:00 2001 From: TheMode Date: Sat, 4 Sep 2021 03:40:22 +0200 Subject: [PATCH] Ensure that the read buffer can contain a single full packet Signed-off-by: TheMode --- src/main/java/net/minestom/server/network/socket/Worker.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/minestom/server/network/socket/Worker.java b/src/main/java/net/minestom/server/network/socket/Worker.java index eb23c87f8..fbbab521d 100644 --- a/src/main/java/net/minestom/server/network/socket/Worker.java +++ b/src/main/java/net/minestom/server/network/socket/Worker.java @@ -40,7 +40,7 @@ public final class Worker extends Thread { final SocketChannel channel = (SocketChannel) key.channel(); if (!channel.isOpen()) return; if (!key.isReadable()) return; - var connection = connectionMap.get(channel); + PlayerSocketConnection connection = connectionMap.get(channel); try { var readBuffer = context.readBuffer; // Consume last incomplete packet @@ -92,7 +92,7 @@ public final class Worker extends Thread { * Contains objects that we can be shared across all the connection of a {@link Worker worker}. */ public static final class Context { - public final BinaryBuffer readBuffer = BinaryBuffer.ofSize(Server.SOCKET_BUFFER_SIZE); + public final BinaryBuffer readBuffer = BinaryBuffer.ofSize(Server.MAX_PACKET_SIZE); public final BinaryBuffer contentBuffer = BinaryBuffer.ofSize(Server.MAX_PACKET_SIZE); public final Inflater inflater = new Inflater();