@Async aspect should clear cached executors when different BeanFactory set by cdalexndr · Pull Request #28201 · spring-projects/spring-framework (original) (raw)

@cdalexndr

@cdalexndr cdalexndr commented

Mar 19, 2022

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

March 19, 2022 22:41

@cdalexndr

[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)

@cdalexndr

[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 spring-projects-issues added the status: waiting-for-triage

An issue we've not yet triaged or decided on

label

Mar 19, 2022

cdalexndr added 2 commits

March 20, 2022 00:49

@cdalexndr

[fix stylechecks](/spring-projects/spring-framework/pull/28201/commits/cce67937a3b398a5cb8db605a96726ad5945cad9 "fix stylechecks")

[cce6793](/spring-projects/spring-framework/pull/28201/commits/cce67937a3b398a5cb8db605a96726ad5945cad9)

@cdalexndr

[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

andrei-ivanov reviewed Mar 20, 2022

View reviewed changes

Comment thread

spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java Outdated

@sbrannen sbrannen added in: core

Issues in core modules (aop, beans, core, context, expression)

type: enhancement

A general enhancement

labels

Mar 20, 2022

sbrannen

sbrannen requested changes Mar 20, 2022

View reviewed changes

Comment thread

spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java Outdated

@sbrannen

sbrannen commented

Mar 20, 2022

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 sbrannen added the status: waiting-for-feedback

We need additional information before we can continue

label

Mar 20, 2022

@cdalexndr

cdalexndr commented

Mar 20, 2022

Copy link Copy Markdown

Author

@sbrannen updated description

sbrannen reacted with thumbs up emoji

@spring-projects-issues 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

Mar 20, 2022

@sbrannen

sbrannen commented

Mar 20, 2022

Copy link Copy Markdown

Member

@cdalexndr

[requested style change](/spring-projects/spring-framework/pull/28201/commits/006f918e606d516158bf14dbb9ab5643508fe615 "requested style change")

[006f918](/spring-projects/spring-framework/pull/28201/commits/006f918e606d516158bf14dbb9ab5643508fe615)

@cdalexndr cdalexndr requested a review from sbrannen

March 20, 2022 17:27

@jhoeller jhoeller changed the title@Async aspect fix change bean factory @Async aspect should clear cached executors when different BeanFactory set

Nov 23, 2023

@jhoeller jhoeller removed the status: waiting-for-triage

An issue we've not yet triaged or decided on

label

Nov 23, 2023

@jhoeller jhoeller added this to the 6.1.2 milestone

Nov 23, 2023

@jhoeller

jhoeller commented

Nov 23, 2023

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 jhoeller self-assigned this

Nov 23, 2023

@jhoeller jhoeller closed this in[121e354](/spring-projects/spring-framework/commit/121e3540cc4cc6d09b546835ee910ecf03d02dc3)

Nov 23, 2023

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 }})