-
Notifications
You must be signed in to change notification settings - Fork 353
setConnectionTimeout on RestTemplateBuilder is not Working #954
Comments
Hi, I just checked why. The So those methods need some entries for |
Yes you are right .. wouldn't have thought that this is so easy fixes the issue ... would be nice though if RestTemplateBuilder will have this out of the box .. One more thing .. do you know why all returned classes from a RestTemplate call Quarkus currently does this automatically for everything annotated with "RegisterRestCLient" |
The `connectTimeout` `readTimeout` and `bufferRequestBody` methods on `RestTemplateBuilder` uses reflection to access underlying `ClientHttpRequestFactory` implementation class. Currently, type hints for `HttpComponentsClientHttpRequestFactory` and `OkHttp3ClientHttpRequestFactory` exist, but the fallback request factory, `SimpleClientHttpRequestFactory` hint doesn't exist. Therefore, when `RestTemplate` doesn't detect either commons-client or okhttp, it falls back to the `SimpleClientHttpRequestFactory` and the reflective access fails to find the class. This PR simply adds a hint to expose `SimpleClientHttpRequestFactory`, so that above reflective methods on `RestTemplateBuilder` will have access to it. Fixes spring-atticgh-954
I have created a PR to add a type hint for
Yeah, I think so. I think one way to achieve it would be spring-aot may look for the return types from controllers and automatically register them. |
Thank you |
The `connectTimeout` `readTimeout` and `bufferRequestBody` methods on `RestTemplateBuilder` uses reflection to access underlying `ClientHttpRequestFactory` implementation class. Currently, type hints for `HttpComponentsClientHttpRequestFactory` and `OkHttp3ClientHttpRequestFactory` exist, but the fallback request factory, `SimpleClientHttpRequestFactory` hint doesn't exist. Therefore, when `RestTemplate` doesn't detect either commons-client or okhttp, it falls back to the `SimpleClientHttpRequestFactory` and the reflective access fails to find the class. This PR simply adds a hint to expose `SimpleClientHttpRequestFactory`, so that above reflective methods on `RestTemplateBuilder` will have access to it. Fixes gh-954
Imagine the following code
final RestTemplate restTemplate = new RestTemplateBuilder()
.setConnectTimeout(Duration.ofMillis(timeout))
.setReadTimeout(Duration.ofMillis(timeout))
.build();
While working in normal mode, a call inside a Native Image will crash with:
"SimpleClientHttpRequestFactory does not have a suitable setConnectTimeout method"
Would be nice if this can be fixed.
The text was updated successfully, but these errors were encountered: