spring-projects / spring-projects/spring-framework
Scheduled method is not invoked via proxy [SPR-13914]
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
Mitchell Bosecke opened SPR-13914 and commented
I have several methods annotated with @scheduled and the majority of them run just fine but one of them in particular is not invoked via a proxy, it is invoked directly. The method is on a class annotated with @Service and @Transactional and that class has an appropriate interface with the method signature on it; i.e. I'm using JDK dynamic proxies.
The @scheduled annotation is on the implementation of the method. There is nothing unique about this method compared to my other @scheduled methods as far as I can tell.
That exact same method, when invoked via a web endpoint works as expected (via proxy and a transaction is available).
I've included some example code in the linked stack overflow post; let me know if I should copy some of that here.
Affects: 3.2.16
Reference URL: http://stackoverflow.com/questions/35184189/spring-scheduled-method-not-invoked-via-proxy-therefore-no-transaction
Issue Links:
- #20469 EnableAsync prevents EnableCaching from working in self-injection scenarios
- #18389 Consistent validation of annotated methods behind AOP proxies
- #18226
@EventListenerdoes not work if put it at method in class that implements interface
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
The issue names @Scheduled, @Transactional, JDK dynamic proxies, and related proxy-based annotation issues, but provides no repository file or test. Start by reproducing the behavior from the linked example and tracing scheduled-method invocation and proxy handling. Done means the reported method is invoked consistently through the expected proxy, with a regression test covering the case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100