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
This commit is contained in:
Marcin Grzejszczak
2019-07-26 10:36:24 +02:00
parent b96392c0f3
commit d642ffd09a

View File

@@ -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;
}