Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spring-issuemaster opened this issue Aug 11, 2018 · 2 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Aug 11, 2018

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-projects/spring-framework-issues#182

Issue Links:

  • #21472 Avoid unnecessary synthesizable annotation processing

Backported to: 4.3.19

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Aug 11, 2018

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.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Aug 11, 2018

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.