@Async aspect should clear cached executors when different BeanFactory set by cdalexndr · Pull Request #28201 · spring-projects/spring-framework (original) (raw)
cdalexndr commented
•
edited
Loading
Copy link Copy Markdown
When using AspectJ and multi-context (ex: testing), the bean factory needs to be changed on the singleton aspect.
This fix clears cached method executors when changing bean factory.
If the first context was previously closed with the executors, then an error will be thrown when trying to reuse the closed executor.
cdalexndr added 2 commits
[Reset cached executors on changed bf](/spring-projects/spring-framework/pull/28201/commits/5108ad2c88ef33b9855c0b6d723f763668ad062a "Reset cached executors on changed bf")
[5108ad2](/spring-projects/spring-framework/pull/28201/commits/5108ad2c88ef33b9855c0b6d723f763668ad062a)
[Merge branch 'spring-projects:main' into fix-async-aspect-bf](/spring-projects/spring-framework/pull/28201/commits/6d253f48d9b71c30f59cfc0b7c551301017ed29b "Merge branch 'spring-projects:main' into fix-async-aspect-bf")
[6d253f4](/spring-projects/spring-framework/pull/28201/commits/6d253f48d9b71c30f59cfc0b7c551301017ed29b)
spring-projects-issues added the status: waiting-for-triage
An issue we've not yet triaged or decided on
label
cdalexndr added 2 commits
[fix stylechecks](/spring-projects/spring-framework/pull/28201/commits/cce67937a3b398a5cb8db605a96726ad5945cad9 "fix stylechecks")
[cce6793](/spring-projects/spring-framework/pull/28201/commits/cce67937a3b398a5cb8db605a96726ad5945cad9)
[Merge remote-tracking branch 'origin/fix-async-aspect-bf' into fix-as…](/spring-projects/spring-framework/pull/28201/commits/5a7c2217a1904de41c789b311ee6e17387ca7311 "Merge remote-tracking branch 'origin/fix-async-aspect-bf' into fix-async-aspect-bf")
[5a7c221](/spring-projects/spring-framework/pull/28201/commits/5a7c2217a1904de41c789b311ee6e17387ca7311)
…ync-aspect-bf
andrei-ivanov reviewed Mar 20, 2022
Comment thread
spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java Outdated
Issues in core modules (aop, beans, core, context, expression)
A general enhancement
labels
sbrannen requested changes Mar 20, 2022
Comment thread
spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java Outdated
sbrannen commented
Copy link Copy Markdown
Member
@cdalexndr, is there an existing issue associated with this "fix"?
If not, can you please add more information to this PR's description to explain the rationale and what error cases the proposed change fixes?
sbrannen added the status: waiting-for-feedback
We need additional information before we can continue
label
cdalexndr commented
Copy link Copy Markdown
Author
@sbrannen updated description
sbrannen reacted with thumbs up emoji
spring-projects-issues added status: feedback-provided
Feedback has been provided
and removed status: waiting-for-feedback
We need additional information before we can continue
labels
sbrannen commented
Copy link Copy Markdown
Member
Related Issues
- TestContext framework should support one AspectJ instance per ApplicationContext [SPR-6353] #11019
- Transaction is not started when two spring contexts are created during tests using AspectJ load time weaving [SPR-7238] #11897
- AnnotationTransactionAspect retains reference to JpaTransactionManager from closed context [SPR-12518] #17123
- Dependency injection of @Configurable objects should work across test suites [SPR-6121] #10789
- AnnotationTransactionAspect retains reference to closed BeanFactory [SPR-7964] #12619
[requested style change](/spring-projects/spring-framework/pull/28201/commits/006f918e606d516158bf14dbb9ab5643508fe615 "requested style change")
[006f918](/spring-projects/spring-framework/pull/28201/commits/006f918e606d516158bf14dbb9ab5643508fe615)
cdalexndr requested a review from sbrannen
jhoeller changed the title
@Async aspect fix change bean factory @Async aspect should clear cached executors when different BeanFactory set
jhoeller removed the status: waiting-for-triage
An issue we've not yet triaged or decided on
label
jhoeller added this to the 6.1.2 milestone
jhoeller commented
Copy link Copy Markdown
Contributor
While I do not see the need for a DisposableBean implementation as the PR suggests, we can simply clear the cached executors in setBeanFactory directly (for scenarios where the instance is reused). I'll resolve it along those lines.
Thanks for the PR, in any case!
jhoeller self-assigned this
jhoeller closed this in
[121e354](/spring-projects/spring-framework/commit/121e3540cc4cc6d09b546835ee910ecf03d02dc3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})