Merge branch '4.0.x'

Closes gh-49326
This commit is contained in:
Andy Wilkinson
2026-02-25 15:20:59 +00:00
2 changed files with 29 additions and 0 deletions
@@ -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);
}
}
}
@@ -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