spring-projects / spring-projects/spring-framework

Scheduled method is not invoked via proxy [SPR-13914]

Open
#18,488 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: core type: bug
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 @EventListener does not work if put it at method in class that implements interface

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.