OutOfMemoryError caused by nested UnsatisfiedDependencyExceptions [SPR-14607] #19175
Comments
Juergen Hoeller commented Good point, that duplication of the nested exception message is a waste in any case. I've removed it for 4.3.3, also fine-tuning our exception message building to avoid an empty ": " clause. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Stephan Neumann opened SPR-14607 and commented
The new error logging format of UnsatisfiedDependencyInjection introduced in Spring 4.3 can cause a OutOfMemoryError. When the constructor
is used (for example when a field with an
@Inject
annotation can't be resolved), the exception message of the causing exception is included twice in the current exception message, once by UnsatisfiedDependencyException, once by NestedRuntimeException which is a superclass of UnsatisfiedDependencyException. The exception message format looks like this:This makes it more than double the size of the message of the causing exception and causes exponential growth of memory consumption. If the nesting level is high enough the application will crash with an OutOfMemoryError instead of logging the root cause of the context creation failure, which is hardly the goal of the new logging format.
I suggest to change the constructor definition to:
This makes the causing exception message only be included once as nested exception text.
Example project to reproduce error & logoutput is attached.
Affects: 4.3 GA
Attachments:
Issue Links:
1 votes, 3 watchers
The text was updated successfully, but these errors were encountered: