From 687610dd5f5c41c99ac9e7161481396a3c2305ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Jandre?= <48719461+JoaoJandre@users.noreply.github.com> Date: Thu, 4 Jan 2024 08:57:24 -0300 Subject: [PATCH] Fix bootstrap exceptions (#8397) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During management server initialization, some EmptyStackException and BeansException exceptions are always thrown; These exceptions do not affect ACS, however, they can cause confusion when observing the management server startup logs with DEBUG level on. The causes of the exceptions have been addressed. Co-authored-by: João Jandre --- .../model/impl/DefaultModuleDefinitionSet.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/model/impl/DefaultModuleDefinitionSet.java b/framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/model/impl/DefaultModuleDefinitionSet.java index 83d2feaa845..6c03c3ce9e1 100644 --- a/framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/model/impl/DefaultModuleDefinitionSet.java +++ b/framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/model/impl/DefaultModuleDefinitionSet.java @@ -101,9 +101,13 @@ public class DefaultModuleDefinitionSet implements ModuleDefinitionSet { log.debug(String.format("Trying to obtain module [%s] context.", moduleDefinitionName)); ApplicationContext context = getApplicationContext(moduleDefinitionName); try { - Runnable runnable = context.getBean("moduleStartup", Runnable.class); - log.info(String.format("Starting module [%s].", moduleDefinitionName)); - runnable.run(); + if (context.containsBean("moduleStartup")) { + Runnable runnable = context.getBean("moduleStartup", Runnable.class); + log.info(String.format("Starting module [%s].", moduleDefinitionName)); + runnable.run(); + } else { + log.debug(String.format("Could not get module [%s] context bean.", moduleDefinitionName)); + } } catch (BeansException e) { log.warn(String.format("Failed to start module [%s] due to: [%s].", moduleDefinitionName, e.getMessage())); if (log.isDebugEnabled()) { @@ -126,6 +130,10 @@ public class DefaultModuleDefinitionSet implements ModuleDefinitionSet { public void with(ModuleDefinition def, Stack parents) { try { String moduleDefinitionName = def.getName(); + if (parents.isEmpty()) { + log.debug(String.format("Could not find module [%s] context as they have no parents.", moduleDefinitionName)); + return; + } log.debug(String.format("Trying to obtain module [%s] context.", moduleDefinitionName)); ApplicationContext parent = getApplicationContext(parents.peek().getName()); log.debug(String.format("Trying to load module [%s] context.", moduleDefinitionName));