From 182c117dc502bfb488d217a21df812ec2a14b80d Mon Sep 17 00:00:00 2001 From: Leymooo Date: Thu, 30 Aug 2018 14:34:30 +0300 Subject: [PATCH] Shutdown logger to flush queue before call a System#exit --- .../java/com/velocitypowered/proxy/VelocityServer.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index 13fccef60..d3f8cc295 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -50,6 +50,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicBoolean; public class VelocityServer implements ProxyServer { + private static final Logger logger = LogManager.getLogger(VelocityServer.class); public static final Gson GSON = new GsonBuilder() .registerTypeHierarchyAdapter(Component.class, new GsonComponentSerializer()) @@ -116,10 +117,12 @@ public class VelocityServer implements ProxyServer { if (!configuration.validate()) { logger.error("Your configuration is invalid. Velocity will refuse to start up until the errors are resolved."); + LogManager.shutdown(); System.exit(1); } } catch (IOException e) { logger.error("Unable to load your velocity.toml. The server will shut down.", e); + LogManager.shutdown(); System.exit(1); } @@ -192,7 +195,9 @@ public class VelocityServer implements ProxyServer { } public void shutdown() { - if (!shutdownInProgress.compareAndSet(false, true)) return; + if (!shutdownInProgress.compareAndSet(false, true)) { + return; + } logger.info("Shutting down the proxy..."); for (ConnectedPlayer player : ImmutableList.copyOf(connectionsByUuid.values())) {