Skip to content

Commit c595077

Browse files
Ignore NoSuchElementException on channel handler removal
1 parent 4d451bc commit c595077

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

invui/src/main/java/xyz/xenondevs/invui/internal/network/PacketListener.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,14 @@ private void injectChannelHandler(Player player) {
109109
private void removeChannelHandler(Player player) {
110110
packetHandlers.remove(player.getUniqueId());
111111
var channel = ((CraftPlayer) player).getHandle().connection.connection.channel;
112-
channel.pipeline().remove(invuiPacketHandlerName);
112+
113+
try {
114+
channel.pipeline().remove(invuiPacketHandlerName);
115+
} catch (NoSuchElementException ignored) {
116+
// On server shutdown, the handler may have already been removed.
117+
// Checking whether the handler is still present before removing it
118+
// could cause a race condition, so we just catch the exception instead.
119+
}
113120
}
114121

115122
private static class PacketHandler extends ChannelDuplexHandler {

0 commit comments

Comments
 (0)