Skip to content

Commit d831f37

Browse files
committed
framework/spring: throw RuntimeException when fail to start or load a module
1 parent 4a49ffa commit d831f37

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public void with(ComponentLifecycle lifecycle) {
7474
lifecycle.start();
7575
} catch (Exception e) {
7676
logger.error("Error on starting bean {} - {}", lifecycle.getName(), e.getMessage(), e);
77+
throw new CloudRuntimeException("Failed to start bean [" + lifecycle.getName() + "]", e);
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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public void with(ModuleDefinition def, Stack<ModuleDefinition> parents) {
116116
if (logger.isDebugEnabled()) {
117117
logger.debug(String.format("module start failure of module [%s] was due to: ", moduleDefinitionName), e);
118118
}
119+
throw new RuntimeException(String.format("Failed to start module [%s]", moduleDefinitionName), e);
119120
}
120121
} catch (EmptyStackException e) {
121122
logger.warn(String.format("Failed to obtain module context due to [%s]. Using root context instead.", e.getMessage()));
@@ -147,10 +148,11 @@ public void with(ModuleDefinition def, Stack<ModuleDefinition> parents) {
147148
logger.debug("Failed to obtain module context: ", e);
148149
}
149150
} catch (BeansException e) {
150-
logger.warn(String.format("Failed to start module [%s] due to: [%s].", def.getName(), e.getMessage()));
151+
logger.warn(String.format("Failed to load module [%s] due to: [%s].", def.getName(), e.getMessage()));
151152
if (logger.isDebugEnabled()) {
152-
logger.debug(String.format("module start failure of module [%s] was due to: ", def.getName()), e);
153+
logger.debug(String.format("module load failure of module [%s] was due to: ", def.getName()), e);
153154
}
155+
throw new RuntimeException(String.format("Failed to load module [%s]", def.getName()), e);
154156
}
155157
}
156158
});

0 commit comments

Comments
 (0)