mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-24 02:09:05 +00:00
Merge branch '4.0.x'
Closes gh-49326
This commit is contained in:
+15
@@ -21,9 +21,14 @@ import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
import org.springframework.boot.context.properties.bind.Bindable;
|
||||
import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar;
|
||||
import org.springframework.boot.context.properties.bind.Binder;
|
||||
import org.springframework.boot.http.client.autoconfigure.HttpClientProperties;
|
||||
import org.springframework.boot.http.client.autoconfigure.service.HttpServiceClientProperties.HttpServiceClientPropertiesRuntimeHints;
|
||||
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
@@ -34,6 +39,7 @@ import org.springframework.core.env.Environment;
|
||||
* @author Phillip Webb
|
||||
* @since 4.0.0
|
||||
*/
|
||||
@ImportRuntimeHints(HttpServiceClientPropertiesRuntimeHints.class)
|
||||
public class HttpServiceClientProperties {
|
||||
|
||||
private final Map<String, HttpClientProperties> properties;
|
||||
@@ -58,4 +64,13 @@ public class HttpServiceClientProperties {
|
||||
.orElse(Collections.emptyMap()));
|
||||
}
|
||||
|
||||
static class HttpServiceClientPropertiesRuntimeHints implements RuntimeHintsRegistrar {
|
||||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
|
||||
BindableRuntimeHintsRegistrar.forTypes(HttpClientProperties.class).registerHints(hints, classLoader);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+14
@@ -22,9 +22,13 @@ import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.http.client.HttpRedirects;
|
||||
import org.springframework.boot.http.client.autoconfigure.ApiversionProperties;
|
||||
import org.springframework.boot.http.client.autoconfigure.HttpClientProperties;
|
||||
import org.springframework.boot.http.client.autoconfigure.service.HttpServiceClientProperties.HttpServiceClientPropertiesRuntimeHints;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
|
||||
@@ -66,6 +70,16 @@ class HttpServiceClientPropertiesTests {
|
||||
assertThat(c3).isNotNull();
|
||||
assertThat(c3.getBaseUrl()).isEqualTo("https://example.com/phil");
|
||||
assertThat(properties.get("c4")).isNull();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void registersHintsForBindingOfHttpClientProperties() {
|
||||
RuntimeHints hints = new RuntimeHints();
|
||||
new HttpServiceClientPropertiesRuntimeHints().registerHints(hints, getClass().getClassLoader());
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(HttpClientProperties.class)).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(ApiversionProperties.class)).accepts(hints);
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(ApiversionProperties.Insert.class)).accepts(hints);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
Reference in New Issue
Block a user