From 44a1d27b34ae5565f72c03959a36ff2d6e6124b0 Mon Sep 17 00:00:00 2001 From: Andreas Haufler Date: Fri, 13 Oct 2023 20:34:26 +0200 Subject: [PATCH 1/3] Fixes a bunch of typos --- src/main/java/sirius/kernel/Setup.java | 14 +++++++------- src/main/java/sirius/kernel/async/Operation.java | 6 +++--- .../sirius/kernel/timer/EndOfDayTaskExecutor.java | 2 +- src/main/java/sirius/kernel/timer/Timers.java | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/sirius/kernel/Setup.java b/src/main/java/sirius/kernel/Setup.java index e1556f2a..1e0b47d7 100644 --- a/src/main/java/sirius/kernel/Setup.java +++ b/src/main/java/sirius/kernel/Setup.java @@ -238,7 +238,7 @@ protected void setupEncoding() { /** * Sets the DNS cache to a sane value. *

- * By default java infinitely caches all DNS entries. Will be changed to 10 seconds... + * By default, java infinitely caches all DNS entries. Will be changed to 10 seconds... */ protected void setupDNSCache() { Sirius.LOG.FINE("Setting DNS-Cache to 10 seconds..."); @@ -268,7 +268,7 @@ protected static Value getProperty(String property, Object defaultValue, String * Initializes log4j as logging framework. *

* In development mode, we log everything to the console. In production mode, we use a rolling file appender and - * log into the logs directory. + * log into the "logs" directory. */ protected void setupLogging() { Logger rootLogger = LogManager.getLogManager().getLogger(""); @@ -330,8 +330,8 @@ private Config loadConfig(String resourceName, Producer configMaker, @Nu /** * Loads the main application configuration which is shipped with the app. *

- * By default this loads "application.conf" from the classpath. Also "application-*.conf - * are loaded in case it is splitted into several parts. + * By default, this loads "application.conf" from the classpath. Also, "application-*.conf + * are loaded in case it is split into several parts. * * @return the main application config. This will override all component configs but be overridden by developer, * test and instance configs @@ -361,7 +361,7 @@ public Config loadApplicationConfig() { /** * Applies the test configuration to the given config object. *

- * By default this loads and applies "test.conf" from the classpath. + * By default, this loads and applies "test.conf" from the classpath. * * @param config the config to enhance * @return the enhanced config @@ -396,7 +396,7 @@ public Config applyTestScenarioConfig(@Nullable String scenarioFile, @Nonnull Co /** * Applies the corresponding configuration to the given config object. *

- * By default this loads and applies the given "instance.conf", "develop.conf", "staging.conf" or "productive.conf" + * By default, this loads and applies the given "instance.conf", "develop.conf", "staging.conf" or "productive.conf" * from the file system. * * @param config the config to amend @@ -419,7 +419,7 @@ public Config applyConfig(@Nonnull Config config, @Nonnull String configType) { /** * Loads and parses the environment. *

- * {@link ConfigFactory} by default treats every environment variable as key instead of as path. Therefore we + * {@link ConfigFactory} by default treats every environment variable as key instead of as path. Therefore, we * manually load the environment be treating variables as path so that compound keys like sirius.nodeName * can be specified. * diff --git a/src/main/java/sirius/kernel/async/Operation.java b/src/main/java/sirius/kernel/async/Operation.java index 5840bfcb..21541ff9 100644 --- a/src/main/java/sirius/kernel/async/Operation.java +++ b/src/main/java/sirius/kernel/async/Operation.java @@ -26,12 +26,12 @@ /** * Tracks the execution of a blocking operation. *

- * The operations framework is used to track blocking operations which might possibly hang. As a blocking operation + * The operations framework is used to track blocking operations which might hang. As a blocking operation * cannot be checked by the calling thread itself, the classical alternative would be to fork a thread which * monitors the operation. As this approach does not scale very well, the operations framework creates a - * lighweight Operation object around a potentially blocking operation using a try-with-resources block. + * lightweight Operation object around a potentially blocking operation using a try-with-resources block. *

- * A metrics provider will check for all operations and use its limits (set by component-kernel.conf, + * A metrics provider will check for all operations and use its limits (set by component-050-kernel.conf, * to warn if too many operations are active (or are probably hanging). *

* Other frameworks can provider further help: SIRIUS-WEB e.g. provides a list of all operations diff --git a/src/main/java/sirius/kernel/timer/EndOfDayTaskExecutor.java b/src/main/java/sirius/kernel/timer/EndOfDayTaskExecutor.java index ad71bf7c..890ed307 100644 --- a/src/main/java/sirius/kernel/timer/EndOfDayTaskExecutor.java +++ b/src/main/java/sirius/kernel/timer/EndOfDayTaskExecutor.java @@ -117,7 +117,7 @@ private EndOfDayTaskInfo executeTask(EndOfDayTask task) { Exceptions.handle() .to(Log.BACKGROUND) .error(exception) - .withSystemErrorMessage("An error occured when executing end of day task %s (%s): %s (%s)", + .withSystemErrorMessage("An error occurred when executing end of day task %s (%s): %s (%s)", task.getName(), task.getClass()) .handle(); diff --git a/src/main/java/sirius/kernel/timer/Timers.java b/src/main/java/sirius/kernel/timer/Timers.java index f22480ff..03998b38 100644 --- a/src/main/java/sirius/kernel/timer/Timers.java +++ b/src/main/java/sirius/kernel/timer/Timers.java @@ -112,7 +112,7 @@ public class Timers implements Startable, Stoppable { private static final int RELOAD_INTERVAL = 1000; /** - * Determines the start and stop order of the timers lifecycle. Exposed as public so that + * Determines the start and stop order of the timer's lifecycle. Exposed as public so that * dependent lifecycles can determine their own priority based on this. */ public static final int LIFECYCLE_PRIORITY = 1000; @@ -307,7 +307,7 @@ public void runOneHourTimers() { * Executes all daily timers (implementing EveryDay) if applicable, or if outOfASchedule is true. * * @param currentHour determines the current hour. Most probably this will be wall-clock time. However, for - * out-of-schedule eecution, this can be set to any value. + * out-of-schedule execution, this can be set to any value. */ public void runEveryDayTimers(int currentHour) { runEveryDayTimers(currentHour, false); From 7a768010f25ee2860a0728d1382727fdda5b6b08 Mon Sep 17 00:00:00 2001 From: Andreas Haufler Date: Fri, 13 Oct 2023 20:35:36 +0200 Subject: [PATCH 2/3] Enforces application-x and component-x.conf files to be sorted This way, esp. component.conf files can be numbered to enforced a proper load order in case one file overwrites another. Fixes: SIRI-891 --- src/main/java/sirius/kernel/Setup.java | 9 ++++-- src/main/java/sirius/kernel/Sirius.java | 42 ++++++++++++++----------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/main/java/sirius/kernel/Setup.java b/src/main/java/sirius/kernel/Setup.java index 1e0b47d7..c118db36 100644 --- a/src/main/java/sirius/kernel/Setup.java +++ b/src/main/java/sirius/kernel/Setup.java @@ -33,6 +33,7 @@ import java.util.logging.LogRecord; import java.util.logging.Logger; import java.util.logging.StreamHandler; +import java.util.regex.Matcher; import java.util.regex.Pattern; /** @@ -343,9 +344,11 @@ public Config loadApplicationConfig() { // Load component configurations Sirius.getClasspath() .find(Pattern.compile("application-([^.]*?)\\.conf")) - .forEach(value -> result.set(loadConfig(value.group(), - () -> ConfigFactory.parseResources(loader, value.group()), - result.get()))); + .map(Matcher::group) + .sorted() + .forEach(configPath -> result.set(loadConfig(configPath, + () -> ConfigFactory.parseResources(loader, configPath), + result.get()))); if (Sirius.class.getResource("/application.conf") != null) { result.set(loadConfig("application.conf", diff --git a/src/main/java/sirius/kernel/Sirius.java b/src/main/java/sirius/kernel/Sirius.java index cd248e2c..7567e143 100644 --- a/src/main/java/sirius/kernel/Sirius.java +++ b/src/main/java/sirius/kernel/Sirius.java @@ -34,6 +34,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; import java.util.regex.Pattern; /** @@ -343,27 +344,32 @@ private static void setupApplicationAndSystemConfig() { if (isStartedAsTest()) { // Load test configurations (will override component configs) - classpath.find(Pattern.compile("component-test-([^.]*?)\\.conf")).forEach(value -> { - try { - LOG.INFO("Loading test config: %s", value.group()); - config = config.withFallback(ConfigFactory.parseResources(setup.getLoader(), value.group())); - } catch (Exception exception) { - handleConfigError(value.group(), exception); - } - }); + classpath.find(Pattern.compile("component-test-([^.]*?)\\.conf")) + .map(Matcher::group) + .sorted() + .forEach(configPath -> { + try { + LOG.INFO("Loading test config: %s", configPath); + config = config.withFallback(ConfigFactory.parseResources(setup.getLoader(), configPath)); + } catch (Exception exception) { + handleConfigError(configPath, exception); + } + }); } // Load component configurations - classpath.find(Pattern.compile("component-([^\\-]*?)([^.]*?)\\.conf")).forEach(value -> { - if (!"test".equals(value.group(1))) { - try { - LOG.INFO("Loading config: %s", value.group()); - config = config.withFallback(ConfigFactory.parseResources(setup.getLoader(), value.group())); - } catch (Exception exception) { - handleConfigError(value.group(), exception); - } - } - }); + classpath.find(Pattern.compile("component-([^\\-]*?)([^.]*?)\\.conf")) + .map(Matcher::group) + .filter(configPath -> !"test".equals(configPath)) + .sorted() + .forEach(configPath -> { + try { + LOG.INFO("Loading config: %s", configPath); + config = config.withFallback(ConfigFactory.parseResources(setup.getLoader(), configPath)); + } catch (Exception exception) { + handleConfigError(configPath, exception); + } + }); config = config.resolve(); From a8a7092ee130bb54e16f60d1f6a6a72a9148f3cf Mon Sep 17 00:00:00 2001 From: Andreas Haufler Date: Fri, 13 Oct 2023 20:36:04 +0200 Subject: [PATCH 3/3] Renames component-kernel.conf to support a controlled load order Fixes: SIRI-891 --- README.md | 2 +- src/main/java/sirius/kernel/cache/README.md | 2 +- src/main/java/sirius/kernel/info/README.md | 2 +- src/main/java/sirius/kernel/xml/Outcall.java | 2 +- .../{component-kernel.conf => component-050-kernel.conf} | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename src/main/resources/{component-kernel.conf => component-050-kernel.conf} (100%) diff --git a/README.md b/README.md index 7cac77df..f4c7db7a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ the core frameworks and a fair amount of commonly used classes. ## Important files of this module: -* [Default configuration](src/main/resources/component-kernel.conf) +* [Default configuration](src/main/resources/component-050-kernel.conf) * [Maven setup](pom.xml). ## The Kernel diff --git a/src/main/java/sirius/kernel/cache/README.md b/src/main/java/sirius/kernel/cache/README.md index a919bda1..c5cc5fba 100644 --- a/src/main/java/sirius/kernel/cache/README.md +++ b/src/main/java/sirius/kernel/cache/README.md @@ -2,7 +2,7 @@ [Caches](Cache.java) can be created using the [CacheManager](CacheManager.java). Each cache should be a constant (**static final**). The configuration of a cache is loaded from the -system configuration using **cache** section (see [component-kernel.conf](../../../../resources/component-kernel.conf)). +system configuration using **cache** section (see [component-kernel.conf](../../../../resources/component-050-kernel.conf)). A coherent cache will be synchronized across a cluster with the help of [CacheCoherence](CacheCoherence.java) - [sirius-biz](https://github.com/scireum/sirius-biz) provides an implementation for this using **Redis**. diff --git a/src/main/java/sirius/kernel/info/README.md b/src/main/java/sirius/kernel/info/README.md index c8db8dcc..0201eeee 100644 --- a/src/main/java/sirius/kernel/info/README.md +++ b/src/main/java/sirius/kernel/info/README.md @@ -1,6 +1,6 @@ # Software Distribution Information With the help of variables in the system configuration -(e.g. [component-kernel.conf](../../../../resources/component-kernel.conf)) the +(e.g. [component-kernel.conf](../../../../resources/component-050-kernel.conf)) the product name and revision as well as a list of all installed modules and their version can be queried using [Product](Product.java). diff --git a/src/main/java/sirius/kernel/xml/Outcall.java b/src/main/java/sirius/kernel/xml/Outcall.java index 42d26742..91a6e6cb 100644 --- a/src/main/java/sirius/kernel/xml/Outcall.java +++ b/src/main/java/sirius/kernel/xml/Outcall.java @@ -331,7 +331,7 @@ public void setReadTimeout(int timeoutMillis) { * Sets the connect-timeout and read-timeout to the values specified in the config block http.outcall.timeouts.* * where * equals the configKey parameter. *

- * See the http.outcall.timeouts.soap block in component-kernel.conf for reference. + * See the http.outcall.timeouts.soap block in component-050-kernel.conf for reference. * * @param configKey the config key of the timeout configuration block * @return this for fluent method calls diff --git a/src/main/resources/component-kernel.conf b/src/main/resources/component-050-kernel.conf similarity index 100% rename from src/main/resources/component-kernel.conf rename to src/main/resources/component-050-kernel.conf