From de991616b0b2e95f720e29b4c07005a9f51c9463 Mon Sep 17 00:00:00 2001 From: Scott Frederick Date: Wed, 14 Oct 2020 18:53:38 -0500 Subject: [PATCH] Use config map name for configtree property sources When Kubernetes mounts config maps onto volumes in a pod, it creates hidden files on the pod filesystem with symbolic links to the hidden files. The symlinks are named for the user-provided config map that was mounted, while the hidden files have system-generated names. Prior to this commit, the property sources created by the configtree property source were added to the environment using the system-generated hidden file name instead of the user-provided symlink name. This commit corrects that behavior so the property sources are named as a user would expect. Fixes gh-23232 --- .../boot/env/ConfigTreePropertySource.java | 17 +++++++-- .../env/ConfigTreePropertySourceTests.java | 38 +++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/ConfigTreePropertySource.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/ConfigTreePropertySource.java index dfe552a8d9..09f0119cb5 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/ConfigTreePropertySource.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/ConfigTreePropertySource.java @@ -25,6 +25,7 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.Arrays; import java.util.Collections; import java.util.EnumSet; +import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.TreeMap; @@ -192,7 +193,7 @@ public class ConfigTreePropertySource extends EnumerablePropertySource imp static Map findAll(Path sourceDirectory, Set