From b90547a51322d5f33d3329e92fb23e9fa1523030 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Tue, 24 Dec 2024 23:29:21 +0000 Subject: [PATCH] Fix NetworkingCommonTest causing a stackoverflow when the server is stopped before 50 ticks. --- .../test/networking/common/NetworkingCommonTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fabric-networking-api-v1/src/testmod/java/net/fabricmc/fabric/test/networking/common/NetworkingCommonTest.java b/fabric-networking-api-v1/src/testmod/java/net/fabricmc/fabric/test/networking/common/NetworkingCommonTest.java index a312cd6cad..982c0edf80 100644 --- a/fabric-networking-api-v1/src/testmod/java/net/fabricmc/fabric/test/networking/common/NetworkingCommonTest.java +++ b/fabric-networking-api-v1/src/testmod/java/net/fabricmc/fabric/test/networking/common/NetworkingCommonTest.java @@ -19,6 +19,9 @@ import java.util.ArrayList; import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import net.minecraft.network.PacketByteBuf; import net.minecraft.network.codec.PacketCodec; import net.minecraft.network.codec.PacketCodecs; @@ -36,6 +39,7 @@ import net.fabricmc.fabric.test.networking.NetworkingTestmods; public class NetworkingCommonTest implements ModInitializer { + private static final Logger LOGGER = LoggerFactory.getLogger(NetworkingCommonTest.class); private boolean firstLoad = true; private List receivedPlay = new ArrayList<>(); private List receivedConfig = new ArrayList<>(); @@ -99,6 +103,11 @@ private static void executeIn(MinecraftServer server, int ticks, Runnable runnab server.execute(new Runnable() { @Override public void run() { + if (!server.isRunning()) { + LOGGER.warn("Server is no longer running, cannot execute task"); + return; + } + if (server.getTicks() >= targetTime) { runnable.run(); return;