From 1a42e4bbc6d05385ed923c48805428f0455eed93 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Fri, 28 Jun 2024 18:22:19 +0200 Subject: [PATCH] Fix exception in EngineInformation during startup --- .../java/de/staropensource/sosengine/base/Engine.java | 8 +++++--- .../sosengine/base/data/info/EngineInformation.java | 11 ++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/base/src/main/java/de/staropensource/sosengine/base/Engine.java b/base/src/main/java/de/staropensource/sosengine/base/Engine.java index 33ed081f..af26ff5a 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/Engine.java +++ b/base/src/main/java/de/staropensource/sosengine/base/Engine.java @@ -105,6 +105,9 @@ public final class Engine implements SubsystemMainClass { } long initTime = Miscellaneous.measureExecutionTime(() -> { + // Initialize variables + logger = new LoggerInstance(new LogIssuer(getClass(), CodePart.ENGINE)); + // Initialize EngineConfiguration and load it new EngineConfiguration(); EngineConfiguration.getInstance().loadConfiguration(); @@ -120,9 +123,6 @@ public final class Engine implements SubsystemMainClass { // Start threads startThreads(); - - // Initialize variables - logger = new LoggerInstance(new LogIssuer(getClass(), CodePart.ENGINE)); }); logger.info("Initialized sos!engine v%engine_version% (commit %engine_git_commit_id_long%-%engine_git_branch%, dirty %engine_git_dirty%) in " + initTime + "ms"); @@ -138,6 +138,8 @@ public final class Engine implements SubsystemMainClass { new EngineInformation(); new PlaceholderEngine(); new ShortcodeConverter(); + + EngineInformation.getInstance().load(); } /** diff --git a/base/src/main/java/de/staropensource/sosengine/base/data/info/EngineInformation.java b/base/src/main/java/de/staropensource/sosengine/base/data/info/EngineInformation.java index 742e9e69..00abbcf0 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/data/info/EngineInformation.java +++ b/base/src/main/java/de/staropensource/sosengine/base/data/info/EngineInformation.java @@ -26,6 +26,7 @@ import de.staropensource.sosengine.base.logging.LoggerInstance; import de.staropensource.sosengine.base.types.CodePart; import de.staropensource.sosengine.base.types.VersionType; import de.staropensource.sosengine.base.utility.PropertyParser; +import de.staropensource.sosengine.base.utility.StackTraceParser; import lombok.Getter; import java.io.IOException; @@ -360,8 +361,9 @@ public final class EngineInformation { Properties gradleProperties = new Properties(); InputStream gradleStream = this.getClass().getClassLoader().getResourceAsStream("gradle.properties"); - if (inputStream == null) { - logger.crash("Unable to load build information: The bundled gradle.properties file could not be found. Do symlinks work on the system that built this JAR?"); + if (gradleStream == null) { + System.out.println("Unable to load build information: The bundled gradle.properties file could not be found. Do symlinks work on the system that built this JAR?"); + Engine.getInstance().shutdown(69); return; } @@ -369,7 +371,10 @@ public final class EngineInformation { gradleProperties.load(gradleStream); gradleStream.close(); } catch (IOException exception) { - logger.crash("Unable to load build information: InputStream failed", exception); + StackTraceParser parser = new StackTraceParser(exception); + System.out.println("Unable to load build information: InputStream 'gradleStream' failed"); + System.out.println(parser.getHeader() + "\n" + parser.getStackTrace()); + Engine.getInstance().shutdown(69); return; }