From 65d47295bc1d1ab8853e6dbf22f0f5cfa212797d Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 28 Mar 2019 10:43:27 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=A4=D0=B8=D0=BA=D1=81=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D1=8B=20WriteParamsThread?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launcher/client/ClientLauncher.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java index 2bfead8d..f684ec33 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -295,6 +295,7 @@ private static void launch(ClientProfile profile, Params params) throws Throwabl private static Process process = null; private static boolean clientStarted = false; + private static Thread writeParamsThread; @LauncherAPI public static Process launch( @@ -304,7 +305,11 @@ public static Process launch( LogHelper.debug("Writing ClientLauncher params"); ClientLauncherContext context = new ClientLauncherContext(); clientStarted = false; - CommonHelper.newThread("Client params writter", true, () -> + if(writeParamsThread != null && writeParamsThread.isAlive()) + { + writeParamsThread.interrupt(); + } + writeParamsThread = CommonHelper.newThread("Client params writter", true, () -> { try { try (ServerSocket socket = new ServerSocket()) { @@ -333,7 +338,8 @@ public static Process launch( } catch (IOException e) { LogHelper.error(e); } - }).start(); + }); + writeParamsThread.start(); checkJVMBitsAndVersion(); LogHelper.debug("Resolving JVM binary"); Path javaBin = LauncherGuardManager.getGuardJavaBinPath(); @@ -395,6 +401,7 @@ public static Process launch( { int exitCode = process.exitValue(); LogHelper.error("Process exit code %d", exitCode); + if(writeParamsThread != null && writeParamsThread.isAlive()) writeParamsThread.interrupt(); break; } if(clientStarted)