Skip to content

Commit 062163b

Browse files
committed
Fix package tangle with configuration properties
Fix a package tangle that was introduced when we added cache bypass to `SpringIterableConfigurationPropertySource`. Ideally we should have been able to depend on `env` from `context` but unfortunately the `EnvironmentPostProcessor` interface references `SpringApplication` which needs to use the Binder. The `isImmutable` method has now been moved to `OriginLookup` which removes the immediate tangle. Closes gh-18393
1 parent 615c6d4 commit 062163b

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import java.util.Set;
2626
import java.util.stream.Stream;
2727

28-
import org.springframework.boot.env.OriginTrackedMapPropertySource;
28+
import org.springframework.boot.origin.OriginLookup;
2929
import org.springframework.core.env.EnumerablePropertySource;
3030
import org.springframework.core.env.MapPropertySource;
3131
import org.springframework.core.env.PropertySource;
@@ -236,8 +236,8 @@ static CacheKey get(EnumerablePropertySource<?> source) {
236236
}
237237

238238
private static boolean isImmutable(EnumerablePropertySource<?> source) {
239-
if (source instanceof OriginTrackedMapPropertySource) {
240-
return ((OriginTrackedMapPropertySource) source).isImmutable();
239+
if (source instanceof OriginLookup) {
240+
return ((OriginLookup<?>) source).isImmutable();
241241
}
242242
if (StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME.equals(source.getName())) {
243243
return source.getSource() == System.getenv();

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedMapPropertySource.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.springframework.boot.origin.OriginLookup;
2323
import org.springframework.boot.origin.OriginTrackedValue;
2424
import org.springframework.core.env.MapPropertySource;
25-
import org.springframework.core.env.PropertySource;
2625

2726
/**
2827
* {@link OriginLookup} backed by a {@link Map} containing {@link OriginTrackedValue
@@ -52,6 +51,7 @@ public OriginTrackedMapPropertySource(String name, Map source) {
5251
* @param name the property source name
5352
* @param source the underlying map source
5453
* @param immutable if the underlying source is immutable and guaranteed not to change
54+
* @since 2.2.0
5555
*/
5656
@SuppressWarnings({ "unchecked", "rawtypes" })
5757
public OriginTrackedMapPropertySource(String name, Map source, boolean immutable) {
@@ -77,11 +77,7 @@ public Origin getOrigin(String name) {
7777
return null;
7878
}
7979

80-
/**
81-
* Return {@code true} if this {@link PropertySource} is immutable and has contents
82-
* that will never change.
83-
* @return if the property source is read only
84-
*/
80+
@Override
8581
public boolean isImmutable() {
8682
return this.immutable;
8783
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginLookup.java

+10
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ public interface OriginLookup<K> {
3535
*/
3636
Origin getOrigin(K key);
3737

38+
/**
39+
* Return {@code true} if this lookup is immutable and has contents that will never
40+
* change.
41+
* @return if the lookup is immutable
42+
* @since 2.2.0
43+
*/
44+
default boolean isImmutable() {
45+
return false;
46+
}
47+
3848
/**
3949
* Attempt to lookup the origin from the given source. If the source is not a
4050
* {@link OriginLookup} or if an exception occurs during lookup then {@code null} is

0 commit comments

Comments
 (0)