Description
Andy Wilkinson opened SPR-16822 and commented
We have some code in Spring Boot that's intended to perform initialisation of a DataSource
just before it's first made available to application code. It currently uses a BeanPostProcessor
and uses the post-processing of any DataSource
as the trigger for initializing a DataSource
. For reasons that escape me, this DataSource
may not be the same DataSource
as the one that is being post-processed so it performs a lookup of a bean while another bean is being post-processed. That has caused several problems.
I think we could simplify the above-described logic so that we only perform initialisation of the DataSource
bean that is being post-processed, thereby avoiding the problematic lookup. However, this action that's targeted to a specific bean doesn't feel like a perfect fit for the broader contract of a BeanPostProcessor
. A callback that can be registered for a specific bean would be a better fit for our needs.
We'd like any callback that may be introduced to happen after bean post-processing. The crucial thing is that the callback is invoked before the bean can be used by application code. When I was trying to figure out what to do about the referenced Boot issue, a callback at around the point where AbstractBeanFactory.afterPrototypeCreation(String)
or DefaultSingletonBeanRegistry.afterSingletonCreation(String)
is called seemed to be a good fit. However, this is only based on a visual inspection of the code. I haven't verified that it would work as hoped.
Affects: 5.0.6
Reference URL: spring-projects/spring-boot#13042
2 votes, 8 watchers