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-projects-issues opened this issue Aug 11, 2018 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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

Issue Links:

Backported to: 4.3.19

@spring-projects-issues
Copy link
Collaborator Author

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-projects-issues
Copy link
Collaborator Author

spring-projects-issues 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...

@spring-projects-issues spring-projects-issues added type: bug A general bug status: backported An issue that has been backported to maintenance branches in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 5.0.9 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants