Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Async aspect should clear cached executors when different BeanFactory set #28201

Closed
wants to merge 5 commits into from

Conversation

cdalexndr
Copy link

@cdalexndr cdalexndr commented Mar 19, 2022

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.

@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
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels Mar 20, 2022
@sbrannen
Copy link
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
Copy link
Author

@sbrannen updated description

@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
@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
Copy link
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 Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: feedback-provided Feedback has been provided type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants