Exception during context refresh swallowed by subsequent LifecycleProcessor exception handling [SPR-10000] #14634
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Archie Cobbs opened SPR-10000 and commented
My application had a bug causing an exception to be thrown during construction of a bean.
This caused the application context refresh operation to be aborted. However, in the process of aborting the refresh, an additional exception was thrown by
AbstractApplicationContext.getLifecycleProcessor()
.This second exception got logged to the error log, but the first exception never did.
As a result, it was very difficult to debug what the actual problem was.
The error logs, including the second exception that did get logged, are here (edited for brevity):
It appears that the following snippet of code in
AbstractBeanFactory
(visible in the above stack trace) may be contributing to the problem (but I haven't verified that for sure). Note how the second exception occurs during the call todestroySingleton()
.Possibly relevant: I have a slightly unusual setup where an outer application context contains a bean which is itself an inner application context:
The
applicationContextBean
is a bean that exposes the containing application context. It is set as the parent of the nested context. Note therefresh
constructor parameter isfalse
, so the inner application context is not refreshed untilafterPropertiesSet()
.Bottom line: ideally, secondary exceptions should never occur; but if they do, they should never prevent a primary exception from being logged.
Affects: 3.1.2
Attachments:
Issue Links:
Backported to: 3.2.11
The text was updated successfully, but these errors were encountered: