I stumbled upon the following code in NestedRuntimeException
in org.springframework.core
:
static {
NestedExceptionUtils.class.getName();
}
What is the use of having such a block?
It will eagerly
load the NestedExceptionUtils
class to avoid classloader deadlock. There was a bug reported (SPR-5607) "Non-trivial NestedRuntimeException.getMessage() can cause deadlocks on OSGi" and this is the solution for the same issue.
Edited:
It is mentioned also in the source code as a comment. For full source code docs please follow the link. Here is the part of the source code of NestedRuntimeException
class.
static {
// Eagerly load the NestedExceptionUtils class to avoid classloader deadlock
// issues on OSGi when calling getMessage(). Reported by Don Brown; SPR-5607.
NestedExceptionUtils.class.getName();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With