mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-02 15:29:05 +00:00
Merge branch '3.5.x'
Closes gh-47679
This commit is contained in:
+3
@@ -19,6 +19,7 @@ package org.springframework.boot.http.client;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.time.Duration;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@@ -89,7 +90,9 @@ class ClientHttpRequestFactoryRuntimeHints implements RuntimeHintsRegistrar {
|
||||
private void registerReflectionHints(ReflectionHints hints,
|
||||
Class<? extends ClientHttpRequestFactory> requestFactoryType, Class<?> readTimeoutType) {
|
||||
registerMethod(hints, requestFactoryType, "setConnectTimeout", int.class);
|
||||
registerMethod(hints, requestFactoryType, "setConnectTimeout", Duration.class);
|
||||
registerMethod(hints, requestFactoryType, "setReadTimeout", readTimeoutType);
|
||||
registerMethod(hints, requestFactoryType, "setReadTimeout", Duration.class);
|
||||
}
|
||||
|
||||
private void registerMethod(ReflectionHints hints, Class<? extends ClientHttpRequestFactory> requestFactoryType,
|
||||
|
||||
+42
@@ -18,6 +18,7 @@ package org.springframework.boot.http.client;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.Duration;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -26,6 +27,7 @@ import org.springframework.aot.hint.predicate.ReflectionHintsPredicates;
|
||||
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||
import org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper;
|
||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||
import org.springframework.http.client.JdkClientHttpRequestFactory;
|
||||
import org.springframework.http.client.JettyClientHttpRequestFactory;
|
||||
import org.springframework.http.client.ReactorClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
@@ -60,6 +62,15 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(HttpComponentsClientHttpRequestFactory.class, "setConnectTimeout", int.class)))
|
||||
.accepts(hints);
|
||||
assertThat(reflection.onMethodInvocation(
|
||||
method(HttpComponentsClientHttpRequestFactory.class, "setConnectTimeout", Duration.class)))
|
||||
.accepts(hints);
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(HttpComponentsClientHttpRequestFactory.class, "setReadTimeout", int.class)))
|
||||
.accepts(hints);
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(HttpComponentsClientHttpRequestFactory.class, "setReadTimeout", Duration.class)))
|
||||
.accepts(hints);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -70,9 +81,15 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(JettyClientHttpRequestFactory.class, "setConnectTimeout", int.class)))
|
||||
.accepts(hints);
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(JettyClientHttpRequestFactory.class, "setConnectTimeout", Duration.class)))
|
||||
.accepts(hints);
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(JettyClientHttpRequestFactory.class, "setReadTimeout", long.class)))
|
||||
.accepts(hints);
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(JettyClientHttpRequestFactory.class, "setReadTimeout", Duration.class)))
|
||||
.accepts(hints);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -83,9 +100,15 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(ReactorClientHttpRequestFactory.class, "setConnectTimeout", int.class)))
|
||||
.accepts(hints);
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(ReactorClientHttpRequestFactory.class, "setConnectTimeout", Duration.class)))
|
||||
.accepts(hints);
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(ReactorClientHttpRequestFactory.class, "setReadTimeout", long.class)))
|
||||
.accepts(hints);
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(ReactorClientHttpRequestFactory.class, "setReadTimeout", Duration.class)))
|
||||
.accepts(hints);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -96,9 +119,28 @@ class ClientHttpRequestFactoryRuntimeHintsTests {
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(SimpleClientHttpRequestFactory.class, "setConnectTimeout", int.class)))
|
||||
.accepts(hints);
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(SimpleClientHttpRequestFactory.class, "setConnectTimeout", Duration.class)))
|
||||
.accepts(hints);
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(SimpleClientHttpRequestFactory.class, "setReadTimeout", int.class)))
|
||||
.accepts(hints);
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(SimpleClientHttpRequestFactory.class, "setReadTimeout", Duration.class)))
|
||||
.accepts(hints);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldRegisterJdkHttpHints() {
|
||||
RuntimeHints hints = new RuntimeHints();
|
||||
new ClientHttpRequestFactoryRuntimeHints().registerHints(hints, getClass().getClassLoader());
|
||||
ReflectionHintsPredicates reflection = RuntimeHintsPredicates.reflection();
|
||||
assertThat(
|
||||
reflection.onMethodInvocation(method(JdkClientHttpRequestFactory.class, "setReadTimeout", int.class)))
|
||||
.accepts(hints);
|
||||
assertThat(reflection
|
||||
.onMethodInvocation(method(JdkClientHttpRequestFactory.class, "setReadTimeout", Duration.class)))
|
||||
.accepts(hints);
|
||||
}
|
||||
|
||||
private static Method method(Class<?> target, String name, Class<?>... parameterTypes) {
|
||||
|
||||
Reference in New Issue
Block a user