We have lots of threads stuck inside PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata()
, waiting to refresh metadata of our @Configurable
entities. We don't use @PersistenceUnit
or @PersistenceContext
and thus our metadata are empty. Since version 5.2, emtpy metadata are represented by InjectionMetadata.EMPTY
, which is always evaluated by InjectionMetadata.needsRefresh()
as 'not fresh', because it doesn't containt the target class.
Compared to previous version of spring this was not happening. This error comes likely from version 5.2, the same version as InjectionMetadata.forElements()
became used.
This is, how the stack fragment looks:
Thread 1538: (state = BLOCKED)
- org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(java.lang.String, java.lang.Class, org.springframework.beans.PropertyValues) @bci=49, line=403 (Compiled frame)
- org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessProperties(org.springframework.beans.PropertyValues, java.lang.Object, java.lang.String) @bci=7, line=357 (Compiled frame)
- org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(java.lang.String, org.springframework.beans.factory.support.RootBeanDefinition, org.springframework.beans.BeanWrapper) @bci=289, line=1422 (Compiled frame)
- org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(java.lang.Object, int, boolean) @bci=66, line=393 (Compiled frame)
- org.springframework.beans.factory.wiring.BeanConfigurerSupport.configureBean(java.lang.Object) @bci=172, line=151 (Compiled frame)
- org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect.configureBean(java.lang.Object) @bci=5, line=63 (Compiled frame)
- org.springframework.beans.factory.aspectj.AbstractDependencyInjectionAspect.ajc$afterReturning$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$2$1ea6722c(java.lang.Object) @bci=2, line=88 (Compiled frame)
Comment From: jhoeller
This looks like a duplicate of #24485 - could you please double-check whether this still happens on Spring Framework 5.2.4+?
Comment From: vinov
Yes really is a duplicate. And the cache is working in 5.2.4, as I can see. Thank you.
Comment From: jhoeller
No worries, thanks for the quick check!
Comment From: vinov
Just note for others. A quick workaround is to disable the post processor, simply by throwing a bean with the correct name in the context. The bean can be just an empty class. Do this, only if you don't need mentioned injection.
<bean id="org.springframework.context.annotation.internalPersistenceAnnotationProcessor"
class="a.b.c.PersistenceAnnotationBeanPostProcessorDeactivation"/>