You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
@Scheduled task runs twice on bean with target-class scoped proxy (when injected) [SPR-17166] #21702
in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug
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.
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.
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...
in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug
Activity
spring-projects-issues commentedon 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-projects-issues commentedon Aug 11, 2018
Juergen Hoeller commented
We consistently ignore
ScopedObjectandAopInfrastructureBeanfor@Scheduledand 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-SNAPSHOTor5.0.9.BUILD-SNAPSHOTa try...