opentracing-contrib / java-spring-jaeger

Apache License 2.0
256 stars 95 forks source link

ScheduledAnnotationBeanPostProcessor::postProcessBeforeDestruction is not invoked if tracing is present #100

Open winster opened 4 years ago

winster commented 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

And if opentracing.spring.cloud.scheduled.enabled is set as false, it works as expected