Extend nested placeholders resolution to any CharSequence

See gh-32876
This commit is contained in:
Yanming Zhou
2024-05-23 09:48:05 +08:00
committed by Stéphane Nicoll
parent 181b68088a
commit 5a7bfa9dec
2 changed files with 42 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-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.
@@ -24,6 +24,7 @@ import org.springframework.lang.Nullable;
*
* @author Chris Beams
* @author Juergen Hoeller
* @author Yanming Zhou
* @since 3.1
* @see PropertySource
* @see PropertySources
@@ -84,8 +85,8 @@ public class PropertySourcesPropertyResolver extends AbstractPropertyResolver {
}
Object value = propertySource.getProperty(key);
if (value != null) {
if (resolveNestedPlaceholders && value instanceof String string) {
value = resolveNestedPlaceholders(string);
if (resolveNestedPlaceholders && value instanceof CharSequence cs) {
value = resolveNestedPlaceholders(cs.toString());
}
logKeyFound(key, propertySource, value);
return convertValueIfNecessary(value, targetValueType);