Skip to content

Commit

Permalink
Merge branch '2.1.x' into 2.2.x
Browse files Browse the repository at this point in the history
Closes gh-19526
  • Loading branch information
mbhave committed Jan 3, 2020
2 parents 1320c44 + 24dd416 commit ac46f59
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion spring-boot-project/spring-boot-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -592,6 +593,18 @@ void bindToBeanWithExceptionInGetterForExistingValue() {
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));
Expand Down Expand Up @@ -707,4 +720,18 @@ Map<String, String> getValues() {

}

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;
}

}

}

0 comments on commit ac46f59

Please sign in to comment.