Skip to content

@Scheduled task runs twice on bean with target-class scoped proxy (when injected) [SPR-17166] #21702

Closed

Description

@spring-projects-issues

Markus Malkusch opened SPR-17166 and commented

When a proxied bean has a @Scheduled annotation, that task is executed twice as if there would be two beans. As a user I would expect that a proxied bean still behaves and acts as there would be only one bean. I would expect the task to be executed only once.

If you run the example, you notice two outputs every second, while I would expect only one output per second.


Affects: 4.3.18, 5.0.8

Reference URL: spring-attic/spring-framework-issues#182

Issue Links:

Backported to: 4.3.19

Activity

  1. spring-projects-issues commented on Aug 11, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    This seems to run twice only when the scoped proxy is injected into another bean, not processing the scoped proxy instance itself otherwise at all. This is why it remained unnoticed in our tests. We need to consistently ignore the scoped proxy instance here, independent from the lifecycle and injection scenario.

  2. spring-projects-issues commented on Aug 11, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    We consistently ignore ScopedObject and AopInfrastructureBean for @Scheduled and related post-processing now. This also optimizes annotation introspection along the lines of #21472 on the 5.1 line now, whereas the backports are going to be rather minimal.

    Thanks for raising this! If you get the chance, please give the upcoming 5.1.0.BUILD-SNAPSHOT or 5.0.9.BUILD-SNAPSHOT a try...

  3. added
    type: bug
    status: backported
    in: core
    on Jan 11, 2019
  4. added this to the 5.0.9 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: corestatus: backportedtype: bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions