In a project that has micrometer-tracing with Zipkin + RestTemplate and no WebClient dependency, ZipkinRestTemplateSender tries to hook in. The problem is that we're calling setReadTimeout via the RestTemplateBuilder's API. That in effect is calling org.springframework.http.client.HttpComponentsClientHttpRequestFactory#setReadTimeout which is deprecated and the application context fails to start.
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinRestTemplateSender]: Factory method 'restTemplateSender' threw exception with message: Request factory class org.springframework.http.client.HttpComponentsClientHttpRequestFactory has the setReadTimeout method marked as deprecated
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:171) ~[spring-beans-6.0.0-RC2.jar:6.0.0-RC2]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:648) ~[spring-beans-6.0.0-RC2.jar:6.0.0-RC2]
... 203 common frames omitted
Caused by: java.lang.IllegalStateException: Request factory class org.springframework.http.client.HttpComponentsClientHttpRequestFactory has the setReadTimeout method marked as deprecated
at org.springframework.boot.web.client.RestTemplateBuilder$RequestFactoryCustomizer.findMethod(RestTemplateBuilder.java:791) ~[spring-boot-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
at org.springframework.boot.web.client.RestTemplateBuilder$RequestFactoryCustomizer.setReadTimeout(RestTemplateBuilder.java:774) ~[spring-boot-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
at org.springframework.boot.web.client.RestTemplateBuilder$RequestFactoryCustomizer.accept(RestTemplateBuilder.java:746) ~[spring-boot-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
at org.springframework.boot.web.client.RestTemplateBuilder.buildRequestFactory(RestTemplateBuilder.java:663) ~[spring-boot-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
at org.springframework.boot.web.client.RestTemplateBuilder.configure(RestTemplateBuilder.java:621) ~[spring-boot-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
at org.springframework.boot.web.client.RestTemplateBuilder.build(RestTemplateBuilder.java:596) ~[spring-boot-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
at org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinConfigurations$RestTemplateSenderConfiguration.restTemplateSender(ZipkinConfigurations.java:82) ~[spring-boot-actuator-autoconfigure-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:139) ~[spring-beans-6.0.0-RC2.jar:6.0.0-RC2]
... 204 common frames omitted
Process finished with exit code 1
Comment From: wilkinsona
We're apparently missing a test as this has been broken since Framework 6.0.0-RC1 due to the changes for https://github.com/spring-projects/spring-framework/issues/28925.
Comment From: wilkinsona
The exception is intentional due to these changes. I'm not sure what we can do about this. It feels rather similar to #31496.
Comment From: mhalbritter
Yeah, I agree. I tend to just drop the setReadTimeout in ZipkinConfigurations.RestTemplateSenderConfiguration as there's currently no way from framework side to set that for all possible http clients.
Comment From: wilkinsona
HttpWebServiceMessageSenderBuilder is also affected so I think we're going to have to try to do something.