-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug
Milestone
Description
Liu, Yinwei David opened SPR-6770 and commented
When Spring stops its application context, it will call DefaultLifecycleProcessor to stop all Lifecycle beans in its context. However, it does not catch the exception when it stops beans. The problem of not catching exception is that it can cause the resource leak.
E.g. we have 5 Lifecycle beans which should be stopped, if the second bean throws one Exception which can cause Spring gives up stopping rest beans, so that other beans are unable to release the resource they have which leads to resource leak.
Can we catch the exception during bean.stop() and logging it?
if (bean.isRunning()) {
if (bean instanceof SmartLifecycle) {
((SmartLifecycle) bean).stop(new Runnable() {
public void run() {
latch.countDown();
}
});
}
else {
bean.stop();
}
}
Affects: 3.0 GA
Issue Links:
- Need detailed log for start and stop Lifecycle beans [SPR-6769] #11435 Need detailed log for start and stop Lifecycle beans
Referenced from: commits a897e3f
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug