Ensure lifecycle callbacks are applied to delegate
When wrapping a ThreadPoolTaskExecutor in a bean postprocessor we should take care that the delegate gets the lifecycle callbacks from the container. Otherwise when it is first used, the thread pool will not have been initialized, resulting in an exception. (Can't believe this ever actually worked)
This commit is contained in:
@@ -37,6 +37,7 @@ import org.springframework.util.concurrent.ListenableFuture;
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 1.0.10
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class LazyTraceThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
|
||||
|
||||
private static final Log log = LogFactory.getLog(MethodHandles.lookup().lookupClass());
|
||||
@@ -83,6 +84,17 @@ public class LazyTraceThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
|
||||
return this.delegate.submitListenable(new SpanContinuingTraceCallable<>(tracer(), traceKeys(), spanNamer(), task));
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
this.delegate.destroy();
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
this.delegate.afterPropertiesSet();
|
||||
super.afterPropertiesSet();
|
||||
}
|
||||
|
||||
private Tracer tracer() {
|
||||
if (this.tracer == null) {
|
||||
this.tracer = this.beanFactory.getBean(Tracer.class);
|
||||
|
||||
Reference in New Issue
Block a user