From 1c663e1c04c5d09feef509349aa7c2bddacccbb0 Mon Sep 17 00:00:00 2001 From: Henry Le Grys Date: Mon, 27 Sep 2021 21:10:32 +0100 Subject: [PATCH] Fix java runtime finder breaking when encountering a bad release file Rather than blowing up when a release file can't be parsed, log it and move on. Hopefully a better runtime comes along. --- .../java/com/skcraft/launcher/launch/JavaRuntimeFinder.java | 6 +++++- .../java/com/skcraft/launcher/util/EnvironmentParser.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/launcher/src/main/java/com/skcraft/launcher/launch/JavaRuntimeFinder.java b/launcher/src/main/java/com/skcraft/launcher/launch/JavaRuntimeFinder.java index e230595..209c4ed 100644 --- a/launcher/src/main/java/com/skcraft/launcher/launch/JavaRuntimeFinder.java +++ b/launcher/src/main/java/com/skcraft/launcher/launch/JavaRuntimeFinder.java @@ -11,15 +11,18 @@ import com.skcraft.launcher.util.Environment; import com.skcraft.launcher.util.EnvironmentParser; import com.skcraft.launcher.util.Platform; import com.skcraft.launcher.util.WinRegistry; +import lombok.extern.java.Log; import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.*; +import java.util.logging.Level; /** * Finds the best Java runtime to use. */ +@Log public final class JavaRuntimeFinder { private JavaRuntimeFinder() { @@ -186,7 +189,8 @@ public final class JavaRuntimeFinder { return releaseDetails.get("JAVA_VERSION"); } catch (IOException e) { - throw new RuntimeException("Failed to read release file", e); + log.log(Level.WARNING, "Failed to read release file " + releaseFile.getAbsolutePath(), e); + return null; } } diff --git a/launcher/src/main/java/com/skcraft/launcher/util/EnvironmentParser.java b/launcher/src/main/java/com/skcraft/launcher/util/EnvironmentParser.java index 227afea..159ec63 100644 --- a/launcher/src/main/java/com/skcraft/launcher/util/EnvironmentParser.java +++ b/launcher/src/main/java/com/skcraft/launcher/util/EnvironmentParser.java @@ -83,7 +83,7 @@ public class EnvironmentParser { } private String parseValue() throws IOException { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); while (true) { char c = read();