java-spring-jaeger icon indicating copy to clipboard operation
java-spring-jaeger copied to clipboard

ScheduledAnnotationBeanPostProcessor::postProcessBeforeDestruction is not invoked if tracing is present

Open winster opened this issue 5 years ago • 0 comments

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

winster avatar Jul 14 '20 12:07 winster