[FIX] Фикс работы WriteParamsThread

This commit is contained in:
Gravit 2019-03-28 10:43:27 +07:00
parent 24987bac6c
commit 65d47295bc
No known key found for this signature in database
GPG key ID: 061981E1E85D3216

View file

@ -295,6 +295,7 @@ private static void launch(ClientProfile profile, Params params) throws Throwabl
private static Process process = null; private static Process process = null;
private static boolean clientStarted = false; private static boolean clientStarted = false;
private static Thread writeParamsThread;
@LauncherAPI @LauncherAPI
public static Process launch( public static Process launch(
@ -304,7 +305,11 @@ public static Process launch(
LogHelper.debug("Writing ClientLauncher params"); LogHelper.debug("Writing ClientLauncher params");
ClientLauncherContext context = new ClientLauncherContext(); ClientLauncherContext context = new ClientLauncherContext();
clientStarted = false; clientStarted = false;
CommonHelper.newThread("Client params writter", true, () -> if(writeParamsThread != null && writeParamsThread.isAlive())
{
writeParamsThread.interrupt();
}
writeParamsThread = CommonHelper.newThread("Client params writter", true, () ->
{ {
try { try {
try (ServerSocket socket = new ServerSocket()) { try (ServerSocket socket = new ServerSocket()) {
@ -333,7 +338,8 @@ public static Process launch(
} catch (IOException e) { } catch (IOException e) {
LogHelper.error(e); LogHelper.error(e);
} }
}).start(); });
writeParamsThread.start();
checkJVMBitsAndVersion(); checkJVMBitsAndVersion();
LogHelper.debug("Resolving JVM binary"); LogHelper.debug("Resolving JVM binary");
Path javaBin = LauncherGuardManager.getGuardJavaBinPath(); Path javaBin = LauncherGuardManager.getGuardJavaBinPath();
@ -395,6 +401,7 @@ public static Process launch(
{ {
int exitCode = process.exitValue(); int exitCode = process.exitValue();
LogHelper.error("Process exit code %d", exitCode); LogHelper.error("Process exit code %d", exitCode);
if(writeParamsThread != null && writeParamsThread.isAlive()) writeParamsThread.interrupt();
break; break;
} }
if(clientStarted) if(clientStarted)