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.

Comment From: sbrannen

@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?

Comment From: cdalexndr

@sbrannen updated description

Comment From: sbrannen

Related Issues

  • 11019

  • 11897

  • 17123

  • 10789

  • 12619

Comment From: jhoeller

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!