From d642ffd09a0153ed53658b45f3f3706fc8024e98 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 26 Jul 2019 10:36:24 +0200 Subject: [PATCH] Removed the eager injection of a bean in the configuration class at the point of creating the configuration class, that bean can use httptracing that can be in progress of being created. with this fix we're making the call lazy fixes gh-1354 --- .../web/client/TraceWebClientAutoConfiguration.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/client/TraceWebClientAutoConfiguration.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/client/TraceWebClientAutoConfiguration.java index 533658beb..cfae6daa6 100644 --- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/client/TraceWebClientAutoConfiguration.java +++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/client/TraceWebClientAutoConfiguration.java @@ -84,7 +84,7 @@ public class TraceWebClientAutoConfiguration { protected static class TraceInterceptorConfiguration { @Autowired - private TracingClientHttpRequestInterceptor clientInterceptor; + private BeanFactory beanFactory; @Bean static TraceRestTemplateBeanPostProcessor traceRestTemplateBeanPostProcessor( @@ -95,7 +95,8 @@ public class TraceWebClientAutoConfiguration { @Bean @Order RestTemplateCustomizer traceRestTemplateCustomizer() { - return new TraceRestTemplateCustomizer(this.clientInterceptor); + return new TraceRestTemplateCustomizer( + new LazyTracingClientHttpRequestInterceptor(this.beanFactory)); } } @@ -247,9 +248,9 @@ class RestTemplateInterceptorInjector { class TraceRestTemplateCustomizer implements RestTemplateCustomizer { - private final TracingClientHttpRequestInterceptor interceptor; + private final ClientHttpRequestInterceptor interceptor; - TraceRestTemplateCustomizer(TracingClientHttpRequestInterceptor interceptor) { + TraceRestTemplateCustomizer(ClientHttpRequestInterceptor interceptor) { this.interceptor = interceptor; }