Fix bootstrap exceptions (#8397)

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 <joao@scclouds.com.br>
This commit is contained in:
João Jandre 2024-01-04 08:57:24 -03:00 committed by GitHub
parent 2eaed80435
commit 687610dd5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<ModuleDefinition> 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));