Fix exception in EngineInformation during startup

This commit is contained in:
JeremyStar™ 2024-06-28 18:22:19 +02:00
parent 116bc4b0b9
commit 1a42e4bbc6
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
2 changed files with 13 additions and 6 deletions

View file

@ -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();
}
/**

View file

@ -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;
}