From c5d6534f796738db0177a11d0909a809706c192e Mon Sep 17 00:00:00 2001 From: nscuro Date: Thu, 26 Sep 2024 20:47:36 +0200 Subject: [PATCH] Don't load plugins when `init.and.exit` is enabled Plugins are not (yet) required for init tasks and thus don't need to be loaded. Signed-off-by: nscuro --- .../org/dependencytrack/plugin/PluginInitializer.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/org/dependencytrack/plugin/PluginInitializer.java b/src/main/java/org/dependencytrack/plugin/PluginInitializer.java index 285fe2089..5449f8f31 100644 --- a/src/main/java/org/dependencytrack/plugin/PluginInitializer.java +++ b/src/main/java/org/dependencytrack/plugin/PluginInitializer.java @@ -18,7 +18,10 @@ */ package org.dependencytrack.plugin; +import alpine.Config; import alpine.common.logging.Logger; +import org.dependencytrack.common.ConfigKey; + import jakarta.servlet.ServletContextEvent; import jakarta.servlet.ServletContextListener; @@ -33,6 +36,12 @@ public class PluginInitializer implements ServletContextListener { @Override public void contextInitialized(final ServletContextEvent event) { + if (Config.getInstance().getPropertyAsBoolean(ConfigKey.INIT_AND_EXIT)) { + LOGGER.debug("Not loading plugins because %s is enabled" + .formatted(ConfigKey.INIT_AND_EXIT.getPropertyName())); + return; + } + LOGGER.info("Loading plugins"); pluginManager.loadPlugins(); }