Skip to content

Commit 94348d9

Browse files
committed
Revert "Merge pull request #32876 from quaff"
This reverts commit 3b2a4da, reversing changes made to 181b680. See gh-32876
1 parent d8dcd3a commit 94348d9

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

spring-core/src/main/java/org/springframework/core/env/PropertySourcesPropertyResolver.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -84,8 +84,8 @@ protected <T> T getProperty(String key, Class<T> targetValueType, boolean resolv
8484
}
8585
Object value = propertySource.getProperty(key);
8686
if (value != null) {
87-
if (resolveNestedPlaceholders && value instanceof CharSequence cs) {
88-
value = resolveNestedPlaceholders(cs.toString());
87+
if (resolveNestedPlaceholders && value instanceof String string) {
88+
value = resolveNestedPlaceholders(string);
8989
}
9090
logKeyFound(key, propertySource, value);
9191
return convertValueIfNecessary(value, targetValueType);

spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java

-13
Original file line numberDiff line numberDiff line change
@@ -300,19 +300,6 @@ void resolveNestedPropertyPlaceholders() {
300300
.withMessageContaining("Circular");
301301
}
302302

303-
@Test
304-
void resolveNestedPlaceholdersIfValueIsCharSequence() {
305-
MutablePropertySources ps = new MutablePropertySources();
306-
ps.addFirst(new MockPropertySource()
307-
.withProperty("p1", "v1")
308-
.withProperty("p2", "v2")
309-
.withProperty("p3", new StringBuilder("${p1}:${p2}")));
310-
ConfigurablePropertyResolver pr = new PropertySourcesPropertyResolver(ps);
311-
assertThat(pr.getProperty("p1")).isEqualTo("v1");
312-
assertThat(pr.getProperty("p2")).isEqualTo("v2");
313-
assertThat(pr.getProperty("p3")).isEqualTo("v1:v2");
314-
}
315-
316303
@Test
317304
void ignoreUnresolvableNestedPlaceholdersIsConfigurable() {
318305
MutablePropertySources ps = new MutablePropertySources();

0 commit comments

Comments
 (0)