diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigData.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigData.java index fcb5eb83fc..d9e5a4be8f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigData.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigData.java @@ -118,6 +118,13 @@ public final class ConfigData { @FunctionalInterface public interface PropertySourceOptions { + /** + * {@link PropertySourceOptions} instance that always returns + * {@link Options#NONE}. + * @since 2.4.6 + */ + PropertySourceOptions ALWAYS_NONE = new AlwaysPropertySourceOptions(Options.NONE); + /** * Return the options that should apply for the given property source. * @param propertySource the property source @@ -142,6 +149,9 @@ public final class ConfigData { * @return a new {@link PropertySourceOptions} instance */ static PropertySourceOptions always(Options options) { + if (options == Options.NONE) { + return ALWAYS_NONE; + } return new AlwaysPropertySourceOptions(options); } @@ -175,7 +185,7 @@ public final class ConfigData { /** * No options. */ - public static final Options NONE = Options.of(); + public static final Options NONE = new Options(Collections.emptySet()); private final Set