From bf1967f32ba70e3a349082cd19a8458190d4c78c Mon Sep 17 00:00:00 2001 From: Gravita Date: Tue, 12 Apr 2022 18:46:58 +0700 Subject: [PATCH] [FIX] ServerWrapper shutdown fix --- .../launcher/request/websockets/ClientJSONPoint.java | 12 ++++++++++-- .../pro/gravit/launcher/server/ServerWrapper.java | 1 - 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientJSONPoint.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientJSONPoint.java index c2dda916..7ef2b881 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientJSONPoint.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientJSONPoint.java @@ -25,11 +25,19 @@ import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; public abstract class ClientJSONPoint { - - private static final EventLoopGroup group = new NioEventLoopGroup(); + private static final AtomicInteger counter = new AtomicInteger(); + private static final ThreadFactory threadFactory = (runnable) -> { + Thread t = new Thread(runnable); + t.setName(String.format("Netty Thread #%d", counter.incrementAndGet())); + t.setDaemon(true); + return t; + }; + private static final EventLoopGroup group = new NioEventLoopGroup(threadFactory); @LauncherInject("launcher.certificatePinning") private static boolean isCertificatePinning; protected final Bootstrap bootstrap = new Bootstrap(); diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java index 396bd8c6..ee104166 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java @@ -180,7 +180,6 @@ public void run(String... args) throws Throwable { LogHelper.error(e); System.exit(-1); } - System.exit(0); } public void updateLauncherConfig() {