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
Add native-image support for RestTemplateBuilder #31888
Comments
The interface
which the
I wonder if we should introduce a new interface in Spring Framework for configurable If this isn't possible, we have to include the methods on the implementing classes in the reflection metadata. |
We could add an interface in Boot with multiple implementations for every |
I decided to not refactor the reflection away and went for the |
@mhalbritter does it make sense to refactor the following to add hints only if the method exists: private void registerReflectionHints(ReflectionHints hints,
Class<? extends ClientHttpRequestFactory> requestFactoryType, Consumer<TypeHint.Builder> hintCustomizer) {
hints.registerType(requestFactoryType, (typeHint) -> {
typeHint.withMethod("setConnectTimeout", TypeReference.listOf(int.class), ExecutableMode.INVOKE);
typeHint.withMethod("setReadTimeout", TypeReference.listOf(int.class), ExecutableMode.INVOKE);
typeHint.withMethod("setBufferRequestBody", TypeReference.listOf(boolean.class), ExecutableMode.INVOKE);
hintCustomizer.accept(typeHint);
});
} Since it generates warning while building the native image if for example
If not, Is there any workaround on the application side to fix/clean-up the hint so that we don't see the warning? |
When using
RestTemplateBuilder
in a native-image, for example in this code:then this fails in a native image with this stacktrace:
This can be observed in https://ci.spring.io/teams/spring-aot-smoke-tests/pipelines/spring-aot-smoke-tests-1.0.x/jobs/rest-template/builds/1
The text was updated successfully, but these errors were encountered: