From 94348d9d41764900a6e32a9e54152447929f3692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Thu, 23 May 2024 13:13:02 +0200 Subject: [PATCH] Revert "Merge pull request #32876 from quaff" This reverts commit 3b2a4da023bf7d52d32adc4fef5d9c3de9200ed5, reversing changes made to 181b68088a4218d33772b3666e5f40be78c25673. See gh-32876 --- .../core/env/PropertySourcesPropertyResolver.java | 6 +++--- .../env/PropertySourcesPropertyResolverTests.java | 13 ------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/env/PropertySourcesPropertyResolver.java b/spring-core/src/main/java/org/springframework/core/env/PropertySourcesPropertyResolver.java index 5ab89cf902..b97fad8748 100644 --- a/spring-core/src/main/java/org/springframework/core/env/PropertySourcesPropertyResolver.java +++ b/spring-core/src/main/java/org/springframework/core/env/PropertySourcesPropertyResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2022 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. @@ -84,8 +84,8 @@ public class PropertySourcesPropertyResolver extends AbstractPropertyResolver { } Object value = propertySource.getProperty(key); if (value != null) { - if (resolveNestedPlaceholders && value instanceof CharSequence cs) { - value = resolveNestedPlaceholders(cs.toString()); + if (resolveNestedPlaceholders && value instanceof String string) { + value = resolveNestedPlaceholders(string); } logKeyFound(key, propertySource, value); return convertValueIfNecessary(value, targetValueType); diff --git a/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java b/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java index a6344b1058..d442f6a0cb 100644 --- a/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java @@ -300,19 +300,6 @@ class PropertySourcesPropertyResolverTests { .withMessageContaining("Circular"); } - @Test - void resolveNestedPlaceholdersIfValueIsCharSequence() { - MutablePropertySources ps = new MutablePropertySources(); - ps.addFirst(new MockPropertySource() - .withProperty("p1", "v1") - .withProperty("p2", "v2") - .withProperty("p3", new StringBuilder("${p1}:${p2}"))); - ConfigurablePropertyResolver pr = new PropertySourcesPropertyResolver(ps); - assertThat(pr.getProperty("p1")).isEqualTo("v1"); - assertThat(pr.getProperty("p2")).isEqualTo("v2"); - assertThat(pr.getProperty("p3")).isEqualTo("v1:v2"); - } - @Test void ignoreUnresolvableNestedPlaceholdersIsConfigurable() { MutablePropertySources ps = new MutablePropertySources();