Polish "Resolve property placeholders when binding properties to a Map"

See gh-39507
This commit is contained in:
Scott Frederick
2024-02-11 15:05:48 -06:00
parent 8292104d20
commit f90f29dd12
2 changed files with 5 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -64,8 +64,7 @@ class MapBinder extends AggregateBinder<Map<Object, Object>> {
getContext().setConfigurationProperty(property);
Object result = property.getValue();
result = getContext().getPlaceholdersResolver().resolvePlaceholders(result);
result = getContext().getConverter().convert(result, target);
return result;
return getContext().getConverter().convert(result, target);
}
source = source.filter(name::isAncestorOf);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -615,7 +615,8 @@ class MapBinderTests {
DefaultConversionService conversionService = new DefaultConversionService();
conversionService.addConverter(new MapConverter());
StandardEnvironment environment = new StandardEnvironment();
Binder binder = new Binder(this.sources, new PropertySourcesPlaceholdersResolver(environment), conversionService, null, null);
Binder binder = new Binder(this.sources, new PropertySourcesPlaceholdersResolver(environment),
conversionService, null, null);
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment, "bar=bc");
this.sources.add(new MockConfigurationPropertySource("foo", "a${bar},${bar}d"));
Map<String, String> map = binder.bind("foo", STRING_STRING_MAP).get();