-
Notifications
You must be signed in to change notification settings - Fork 41.1k
setReadTimeout can't be set via Reflective factory on JettyClientHttpRequestFactory #40635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
None of Spring Boot's built-in request factory implementations ( Line 263 in 8b8e263
If you are somehow jave a |
Yes, I do have such a path. We create a RestTemplate using the RestTemplateBuilder. We'd like every request sent by the template to be wrapped by a BufferingRequest (in order to be able to log the request before it's sent), but the nested request should be created as configured by other factories. Hence we use this:
This form of the "requestFactory" method uses |
Reproducer here: sb-40635.zip Works with Boot 3.1.x, fails with 3.2.x and 3.3.x:
|
The HttpComponentsClientHttpRequestFactory
JettyClientHttpRequestFactory
JdkClientHttpRequestFactory
SimpleClientHttpRequestFactory
OkHttp3ClientHttpRequestFactory
We can fix this bei either preferring the We currently assume in the int timeout = Math.toIntExact(readTimeout.toMillis()); I think preferring the |
I'd also search for a method with a |
spring-boot/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/ClientHttpRequestFactories.java
Line 394 in 8b8e263
The above line (in the Reflective factory) tries to find and invoke the
setReadTimeout
method with a parameter of typeint
. However, some of the used factories, e.g. the Jetty one, have other parameter types of this method. Jetty haslong
(here) andDuration
(here).Hence the readTimeout parameter can't be set via the Reflective factory if the real factory is the Jetty one.
IMO the code should look for "setReadTimeout" methods with different parameters (at least
int
,long
andDuration
), and call the first one found.The text was updated successfully, but these errors were encountered: