Skip to content

Commit d092d62

Browse files
author
Dave Syer
committed
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)
1 parent 1d1f28d commit d092d62

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/LazyTraceThreadPoolTaskExecutor.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
* @author Marcin Grzejszczak
3838
* @since 1.0.10
3939
*/
40+
@SuppressWarnings("serial")
4041
public class LazyTraceThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
4142

4243
private static final Log log = LogFactory.getLog(MethodHandles.lookup().lookupClass());
@@ -83,6 +84,17 @@ public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
8384
return this.delegate.submitListenable(new SpanContinuingTraceCallable<>(tracer(), traceKeys(), spanNamer(), task));
8485
}
8586

87+
public void destroy() {
88+
this.delegate.destroy();
89+
super.destroy();
90+
}
91+
92+
@Override
93+
public void afterPropertiesSet() {
94+
this.delegate.afterPropertiesSet();
95+
super.afterPropertiesSet();
96+
}
97+
8698
private Tracer tracer() {
8799
if (this.tracer == null) {
88100
this.tracer = this.beanFactory.getBean(Tracer.class);

0 commit comments

Comments
 (0)