Put a limit on the size of DefaultSingletonBeanRegistry#suppressedExceptions #24902
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: enhancement
A general enhancement
Milestone
Spring 5.1.8
Whilst converting a particularly complex ball-of-mud legacy application from XML config to
@Configuration
-style config, I am finding that diagnosing circular references that triggerBeanCurrentlyInCreationException
s causes anOutOfMemoryError
before any actual exception is thrown during context initialisation. This doesn't happn with the pure XML-based config, only when I mix Java and XML styles.When I look at the
hprof
file, 96% of the 2.5GB heap is retained by theDefaultSingletonBeanRegistry#suppressedExceptions
field, which is full of massively-nestedBeanCreationException
s - 12592 of them, in this case.It woul make sense to me if the
suppressedExceptions
field were to have a size limiter added, to prevent it growing so large. It's only there for diagnostics, and 12000+ exceptons isn't going to help anyone. I on't know what a sensible size imit would be, but more than a few dozen would seem to be unecessary and unhelpful.In my case, the limiter would at least allow the context init to fail "gracefully". I don't know what it is about my set up, but its much too complex for me to post as a test case, sorry.
The text was updated successfully, but these errors were encountered: