commit
ac46f5971f
|
|
@ -189,7 +189,7 @@
|
|||
<spring-batch.version>4.2.1.RELEASE</spring-batch.version>
|
||||
<spring-cloud-connectors.version>2.0.7.RELEASE</spring-cloud-connectors.version>
|
||||
<spring-data-releasetrain.version>Moore-SR3</spring-data-releasetrain.version>
|
||||
<spring-framework.version>5.2.2.RELEASE</spring-framework.version>
|
||||
<spring-framework.version>5.2.3.BUILD-SNAPSHOT</spring-framework.version>
|
||||
<spring-hateoas.version>1.0.2.RELEASE</spring-hateoas.version>
|
||||
<spring-integration.version>5.2.2.RELEASE</spring-integration.version>
|
||||
<spring-kafka.version>2.3.4.RELEASE</spring-kafka.version>
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package org.springframework.boot.context.properties.bind;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -592,6 +593,18 @@ class MapBinderTests {
|
|||
assertThat(result.getValues()).containsExactly(entry("a", "b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindToMapWithWildcardShouldConvertToTheRightType() {
|
||||
// gh-18767
|
||||
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
|
||||
source.put("foo.addresses.localhost[0]", "127.0.0.1");
|
||||
source.put("foo.addresses.localhost[1]", "127.0.0.2");
|
||||
this.sources.add(source);
|
||||
MapWithWildcardProperties result = this.binder.bind("foo", Bindable.of(MapWithWildcardProperties.class)).get();
|
||||
assertThat(result.getAddresses().get("localhost").stream().map(InetAddress::getHostAddress))
|
||||
.containsExactly("127.0.0.1", "127.0.0.2");
|
||||
}
|
||||
|
||||
private <K, V> Bindable<Map<K, V>> getMapBindable(Class<K> keyGeneric, ResolvableType valueType) {
|
||||
ResolvableType keyType = ResolvableType.forClass(keyGeneric);
|
||||
return Bindable.of(ResolvableType.forClassWithGenerics(Map.class, keyType, valueType));
|
||||
|
|
@ -707,4 +720,18 @@ class MapBinderTests {
|
|||
|
||||
}
|
||||
|
||||
static class MapWithWildcardProperties {
|
||||
|
||||
private Map<String, ? extends List<? extends InetAddress>> addresses;
|
||||
|
||||
Map<String, ? extends List<? extends InetAddress>> getAddresses() {
|
||||
return this.addresses;
|
||||
}
|
||||
|
||||
void setAddresses(Map<String, ? extends List<? extends InetAddress>> addresses) {
|
||||
this.addresses = addresses;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue