From ebc418f6ccadb8e8a3ce5f5679fe9b79c6724d56 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sat, 13 Jul 2024 21:50:27 -0400 Subject: [PATCH] Do not use classes from `io.netty.util.internal` In this case, we don't even need a concurrency-friendly MPSC queue, since this code only ever gets run in the event loop associated to the channel, so a simple `ArrayDeque` is enough for our needs. --- .../proxy/protocol/netty/PlayPacketQueueInboundHandler.java | 4 ++-- .../proxy/protocol/netty/PlayPacketQueueOutboundHandler.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/PlayPacketQueueInboundHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/PlayPacketQueueInboundHandler.java index fe553f76a..1affc13bc 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/PlayPacketQueueInboundHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/PlayPacketQueueInboundHandler.java @@ -24,7 +24,7 @@ import com.velocitypowered.proxy.protocol.StateRegistry; import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.util.ReferenceCountUtil; -import io.netty.util.internal.PlatformDependent; +import java.util.ArrayDeque; import java.util.Queue; import org.jetbrains.annotations.NotNull; @@ -42,7 +42,7 @@ import org.jetbrains.annotations.NotNull; public class PlayPacketQueueInboundHandler extends ChannelDuplexHandler { private final StateRegistry.PacketRegistry.ProtocolRegistry registry; - private final Queue queue = PlatformDependent.newMpscQueue(); + private final Queue queue = new ArrayDeque<>(); /** * Provides registries for client & server bound packets. diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/PlayPacketQueueOutboundHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/PlayPacketQueueOutboundHandler.java index d5764ef6a..c57271040 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/PlayPacketQueueOutboundHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/PlayPacketQueueOutboundHandler.java @@ -25,7 +25,7 @@ import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPromise; import io.netty.util.ReferenceCountUtil; -import io.netty.util.internal.PlatformDependent; +import java.util.ArrayDeque; import java.util.Queue; import org.jetbrains.annotations.NotNull; @@ -43,7 +43,7 @@ import org.jetbrains.annotations.NotNull; public class PlayPacketQueueOutboundHandler extends ChannelDuplexHandler { private final StateRegistry.PacketRegistry.ProtocolRegistry registry; - private final Queue queue = PlatformDependent.newMpscQueue(); + private final Queue queue = new ArrayDeque<>(); /** * Provides registries for client & server bound packets.