From 7bc709c32fdbf2ba02e2dca63597567c4bcacecc Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 27 Nov 2024 19:30:58 +0000 Subject: [PATCH] Fix subName from adapted name with value processor Previously, when a configuration property name was created by adapting a source with a value processor, creating sub names from that property name did not work correctly. This broke binding of prefixed environment variables to a map as the ancestor checking did not work. Fixes gh-43304 --- .../source/ConfigurationPropertyName.java | 10 +++++----- .../source/ConfigurationPropertyNameTests.java | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java index 91052105ff3..bd1e7f1dda0 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java @@ -773,7 +773,7 @@ public final class ConfigurationPropertyName implements Comparable value.toString().toLowerCase(Locale.ENGLISH)); + assertThat(name.subName(1)).hasToString("logging.level.one"); + assertThat(name.subName(2)).hasToString("level.one"); + } + @Test void subNameWhenOffsetZeroShouldReturnName() { ConfigurationPropertyName name = ConfigurationPropertyName.of("foo.bar.baz");