Commit 743cf3b2 authored by Madhura Bhave's avatar Madhura Bhave

Merge branch '2.2.x'

Closes gh-19527
parents cc154bbe ac46f597
......@@ -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;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment