spring-projects / spring-projects/spring-framework
AspectJ around aspect called twice when using a Mockito Spy
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
Spring Boot 2.2.0.RELEASE
Using @Async returning a Future cannot be canceled if the @Async method is called from a @SpyBean.
From debugging, it seems the @Async aspect is called twice, first before mockito handling method call then after Mockito calls method so the returned Future is invalid.
Sample project: https://github.com/cdalexndr/spring-boot-issue-18771
Just run gradlew test
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked sample project and run gradlew test to reproduce the failure. Trace the interaction between @Async, @SpyBean, Mockito handling, and the AspectJ aspect; done means the aspect is not applied twice and the returned Future can be canceled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- backend, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100