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 dc3c6d5..5ebcf45 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/Engine.java +++ b/base/src/main/java/de/staropensource/sosengine/base/Engine.java @@ -343,7 +343,7 @@ public final class Engine implements SubsystemMainClass { * @param exitCode code to exit with, from 0-255 * @since 1-alpha0 */ - public void shutdown(@Range(from = 0, to = 255) int exitCode) { + public synchronized void shutdown(@Range(from = 0, to = 255) int exitCode) { logger.info("Shutting engine down"); shuttingDown = true; @@ -379,7 +379,7 @@ public final class Engine implements SubsystemMainClass { * * @since 1-alpha0 */ - public void shutdown() { + public synchronized void shutdown() { shutdown(0); } } diff --git a/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java b/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java index 7440b6b..a32ac8a 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java +++ b/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java @@ -271,7 +271,7 @@ public final class EngineConfiguration implements SubsystemConfiguration { } /** {@inheritDoc} */ - public void loadConfiguration(@NotNull Properties properties) { + public synchronized void loadConfiguration(@NotNull Properties properties) { // Define variables PropertyParser parser = new PropertyParser(properties); @@ -318,12 +318,12 @@ public final class EngineConfiguration implements SubsystemConfiguration { } /** {@inheritDoc} */ - public void loadConfiguration() { + public synchronized void loadConfiguration() { loadConfiguration(System.getProperties()); } /** {@inheritDoc} */ - public void loadDefaultConfiguration() { + public synchronized void loadDefaultConfiguration() { debug = false; debugEvents = false; debugShortcodeConverter = false; diff --git a/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java b/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java index b3743f6..3b10691 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java +++ b/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java @@ -158,7 +158,7 @@ public class EventHelper { * @param clazz event listeners to (p)recompute, set to {@code null} to recompute all cached events * @since 1-alpha0 */ - public static void precomputeEventListeners(@Nullable Class clazz) { + public static synchronized void precomputeEventListeners(@Nullable Class clazz) { if (clazz == null) for (Class event : cachedEventListeners.keySet()) precomputeEventListeners(event); @@ -178,7 +178,7 @@ public class EventHelper { * @param clazz event class to remove cached event listeners for or {@code null} to remove all cached event listeners * @since 1-alpha0 */ - public static void removePrecomputedEventListeners(@Nullable Class clazz) { + public static synchronized void removePrecomputedEventListeners(@Nullable Class clazz) { if (clazz == null) cachedEventListeners.clear(); else 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 444f449..f07b9da 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 @@ -366,7 +366,7 @@ public final class EngineInformation { * * @since 1-alpha1 */ - public static void updateVariables() { + public static synchronized void updateVariables() { LoggerInstance logger = new LoggerInstance(new LogIssuer(EngineInformation.class, CodePart.ENGINE)); // Load properties from bundled gradle.properties diff --git a/base/src/main/java/de/staropensource/sosengine/base/logging/CrashHandler.java b/base/src/main/java/de/staropensource/sosengine/base/logging/CrashHandler.java index ec8da6a..0119df8 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/logging/CrashHandler.java +++ b/base/src/main/java/de/staropensource/sosengine/base/logging/CrashHandler.java @@ -109,7 +109,7 @@ public final class CrashHandler { * @param throwable simply to provide stacktrace and further insight into the crash, can be set to {@code null} * @since 1-alpha0 */ - public static void handleCrash(@NotNull LogIssuer logIssuer, @NotNull String message, @Nullable Throwable throwable) { + public static synchronized void handleCrash(@NotNull LogIssuer logIssuer, @NotNull String message, @Nullable Throwable throwable) { String base = crashTemplate; // Replace '%content%' with crash content @@ -170,7 +170,7 @@ public final class CrashHandler { * But hey, if someone breaks this method (which may be possible idk didn't test it) then congrats! */ @NotNull - private static String processCrashContent(@NotNull LinkedHashMap map, int indentationSize) { + private static synchronized String processCrashContent(@NotNull LinkedHashMap map, int indentationSize) { StringBuilder content = new StringBuilder(); for (Object key : map.keySet()) { @@ -217,7 +217,7 @@ public final class CrashHandler { * @return crash content string * @since 1-alpha0 */ - public static String processCrashContent() { + public static synchronized String processCrashContent() { return processCrashContent(crashContent, 0); } } diff --git a/base/src/main/java/de/staropensource/sosengine/base/logging/Logger.java b/base/src/main/java/de/staropensource/sosengine/base/logging/Logger.java index 5ead8ee..74d6e04 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/logging/Logger.java +++ b/base/src/main/java/de/staropensource/sosengine/base/logging/Logger.java @@ -177,10 +177,6 @@ public final class Logger { * @since 1-alpha1 */ private static void processLogMessage(@NotNull LogIssuer issuer, @NotNull LogLevel level, @NotNull String message) { - // Check if level is allowed - if (level.compareTo(EngineConfiguration.getInstance().getLoggerLevel()) < 0) - return; - // Evaluate all active rules for (LogRule rule : activeRules) { if (rule.evaluate(issuer, level, message)) { @@ -234,6 +230,10 @@ public final class Logger { // Check if engine has initialized if (Engine.getInstance() == null) return; + // Dismiss if level is not allowed + if (level.compareTo(EngineConfiguration.getInstance().getLoggerLevel()) < 0) + return; + if (EngineConfiguration.getInstance().isOptimizeLogging()) // Optimizations enabled, add to message queue queuedMessages.add(new QueuedLogMessage(issuer, level, message)); diff --git a/base/src/main/java/de/staropensource/sosengine/base/utility/DependencyResolver.java b/base/src/main/java/de/staropensource/sosengine/base/utility/DependencyResolver.java index 3542002..314aa88 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/utility/DependencyResolver.java +++ b/base/src/main/java/de/staropensource/sosengine/base/utility/DependencyResolver.java @@ -69,7 +69,7 @@ public final class DependencyResolver { * @return itself * @since 1-alpha1 */ - public DependencyResolver addVector(@NotNull DependencyVector vector) { + public synchronized DependencyResolver addVector(@NotNull DependencyVector vector) { vectors.add(vector); resolved = false; return this; @@ -82,7 +82,7 @@ public final class DependencyResolver { * @return itself * @since 1-alpha1 */ - public DependencyResolver addVectors(@NotNull DependencyVector[] vectors) { + public synchronized DependencyResolver addVectors(@NotNull DependencyVector[] vectors) { addVectors(Arrays.stream(vectors).toList()); resolved = false; return this; @@ -95,7 +95,7 @@ public final class DependencyResolver { * @return itself * @since 1-alpha1 */ - public DependencyResolver addVectors(@NotNull Collection vectors) { + public synchronized DependencyResolver addVectors(@NotNull Collection vectors) { this.vectors.addAll(vectors); resolved = false; return this; @@ -108,7 +108,7 @@ public final class DependencyResolver { * @return itself * @since 1-alpha1 */ - public DependencyResolver addVectors(@NotNull List vectors) { + public synchronized DependencyResolver addVectors(@NotNull List vectors) { this.vectors.addAll(vectors); resolved = false; return this; @@ -121,7 +121,7 @@ public final class DependencyResolver { * @return itself * @since 1-alpha1 */ - public DependencyResolver addVectors(@NotNull ImmutableArrayList vectors) { + public synchronized DependencyResolver addVectors(@NotNull ImmutableArrayList vectors) { this.vectors.addAll(vectors); resolved = false; return this; @@ -134,7 +134,7 @@ public final class DependencyResolver { * @return itself * @since 1-alpha1 */ - public DependencyResolver addVectors(@NotNull ImmutableLinkedList vectors) { + public synchronized DependencyResolver addVectors(@NotNull ImmutableLinkedList vectors) { this.vectors.addAll(vectors); resolved = false; return this; @@ -147,7 +147,7 @@ public final class DependencyResolver { * @return itself * @since 1-alpha1 */ - public DependencyResolver addVectors(@NotNull Set vectors) { + public synchronized DependencyResolver addVectors(@NotNull Set vectors) { this.vectors.addAll(vectors); resolved = false; return this; @@ -163,7 +163,7 @@ public final class DependencyResolver { * @since 1-alpha1 */ @SuppressWarnings("JavaReflectionInvocation") - public DependencyResolver resolve() throws UnmetDependenciesException, UnexpectedThrowableException { + public synchronized DependencyResolver resolve() throws UnmetDependenciesException, UnexpectedThrowableException { Map unmetDependencies = new HashMap<>(); resolved = false;