Skip to content

Commit 288f9a9

Browse files
framework/spring: throw RuntimeException when fail to start or load a module (#13186)
1 parent 6227525 commit 288f9a9

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/CloudStackExtendedLifeCycle.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ public void with(ComponentLifecycle lifecycle) {
7373
try {
7474
lifecycle.start();
7575
} catch (Exception e) {
76-
logger.error("Error on starting bean {} - {}", lifecycle.getName(), e.getMessage(), e);
76+
logger.error("Error on starting bean [{}] due to: {}", lifecycle.getName(), e);
77+
throw new CloudRuntimeException("Failed to start bean [" + lifecycle.getName() + "]");
7778
}
7879

7980
if (lifecycle instanceof ManagementBean) {

framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/model/impl/DefaultModuleDefinitionSet.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,8 @@ public void with(ModuleDefinition def, Stack<ModuleDefinition> parents) {
112112
logger.debug(String.format("Could not get module [%s] context bean.", moduleDefinitionName));
113113
}
114114
} catch (BeansException e) {
115-
logger.warn(String.format("Failed to start module [%s] due to: [%s].", moduleDefinitionName, e.getMessage()));
116-
if (logger.isDebugEnabled()) {
117-
logger.debug(String.format("module start failure of module [%s] was due to: ", moduleDefinitionName), e);
118-
}
115+
logger.error("Failed to start module [{}] due to: {}", def.getName(), e);
116+
throw new RuntimeException(String.format("Failed to start module [%s]", def.getName()));
119117
}
120118
} catch (EmptyStackException e) {
121119
logger.warn(String.format("Failed to obtain module context due to [%s]. Using root context instead.", e.getMessage()));
@@ -147,10 +145,8 @@ public void with(ModuleDefinition def, Stack<ModuleDefinition> parents) {
147145
logger.debug("Failed to obtain module context: ", e);
148146
}
149147
} catch (BeansException e) {
150-
logger.warn(String.format("Failed to start module [%s] due to: [%s].", def.getName(), e.getMessage()));
151-
if (logger.isDebugEnabled()) {
152-
logger.debug(String.format("module start failure of module [%s] was due to: ", def.getName()), e);
153-
}
148+
logger.error("Failed to load module [{}] due to: {}", def.getName(), e);
149+
throw new RuntimeException(String.format("Failed to load module [%s]", def.getName()));
154150
}
155151
}
156152
});

0 commit comments

Comments
 (0)