Open winster opened 4 years ago
A refresh scoped bean with Scheduled annotation does not cancel current scheduled task upon refresh when tracing libraries are present in the classpath (could be sleuth or opentracing-jaeger).
A sample application is given here https://github.com/winster/SpringSchedulerDynamic
Please note that it works as expected if tracing is not there. (A new scheduled task is created and current one is canceled)
Adding some information on debug starting from RefreshScope::refreshAll
1. Without tracing library
RefreshScope::refreshAll -> GenericScope::destroy -> DisposableBeanAdapater::run -> DisposableBeanAdapater::destroy this.beanPostProcessors = ScheduledAnnotationBeanPostProcessor, ApplicationListenerDetector
2. With tracing library
RefreshScope::refreshAll -> GenericScope::destroy -> DisposableBeanAdapater::run -> DisposableBeanAdapater::destroy this.beanPostProcessors = ApplicationListenerDetector
It is noted that ScheduledAnnotationBeanPostProcessor::postProcessBeforeDestruction is not invoked in this case
ScheduledAnnotationBeanPostProcessor::postProcessBeforeDestruction
And if opentracing.spring.cloud.scheduled.enabled is set as false, it works as expected
opentracing.spring.cloud.scheduled.enabled
false
A refresh scoped bean with Scheduled annotation does not cancel current scheduled task upon refresh when tracing libraries are present in the classpath (could be sleuth or opentracing-jaeger).
A sample application is given here https://github.com/winster/SpringSchedulerDynamic
Please note that it works as expected if tracing is not there. (A new scheduled task is created and current one is canceled)
Adding some information on debug starting from RefreshScope::refreshAll
1. Without tracing library
2. With tracing library
It is noted that
ScheduledAnnotationBeanPostProcessor::postProcessBeforeDestruction
is not invoked in this caseAnd if
opentracing.spring.cloud.scheduled.enabled
is set asfalse
, it works as expected