|
|
@ -25,9 +25,11 @@ import java.util.List;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.env.OriginTrackedMapPropertySource;
|
|
|
|
import org.springframework.core.env.EnumerablePropertySource;
|
|
|
|
import org.springframework.core.env.EnumerablePropertySource;
|
|
|
|
import org.springframework.core.env.MapPropertySource;
|
|
|
|
import org.springframework.core.env.MapPropertySource;
|
|
|
|
import org.springframework.core.env.PropertySource;
|
|
|
|
import org.springframework.core.env.PropertySource;
|
|
|
|
|
|
|
|
import org.springframework.core.env.StandardEnvironment;
|
|
|
|
import org.springframework.core.env.SystemEnvironmentPropertySource;
|
|
|
|
import org.springframework.core.env.SystemEnvironmentPropertySource;
|
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
|
|
|
|
|
@ -190,6 +192,9 @@ class SpringIterableConfigurationPropertySource extends SpringConfigurationPrope
|
|
|
|
|
|
|
|
|
|
|
|
private static final class CacheKey {
|
|
|
|
private static final class CacheKey {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final CacheKey IMMUTABLE_PROPERTY_SOURCE = new CacheKey(
|
|
|
|
|
|
|
|
new Object[0]);
|
|
|
|
|
|
|
|
|
|
|
|
private final Object key;
|
|
|
|
private final Object key;
|
|
|
|
|
|
|
|
|
|
|
|
private CacheKey(Object key) {
|
|
|
|
private CacheKey(Object key) {
|
|
|
@ -197,6 +202,9 @@ class SpringIterableConfigurationPropertySource extends SpringConfigurationPrope
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CacheKey copy() {
|
|
|
|
public CacheKey copy() {
|
|
|
|
|
|
|
|
if (this == IMMUTABLE_PROPERTY_SOURCE) {
|
|
|
|
|
|
|
|
return IMMUTABLE_PROPERTY_SOURCE;
|
|
|
|
|
|
|
|
}
|
|
|
|
return new CacheKey(copyKey(this.key));
|
|
|
|
return new CacheKey(copyKey(this.key));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -215,7 +223,8 @@ class SpringIterableConfigurationPropertySource extends SpringConfigurationPrope
|
|
|
|
if (obj == null || getClass() != obj.getClass()) {
|
|
|
|
if (obj == null || getClass() != obj.getClass()) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ObjectUtils.nullSafeEquals(this.key, ((CacheKey) obj).key);
|
|
|
|
CacheKey otherCacheKey = (CacheKey) obj;
|
|
|
|
|
|
|
|
return ObjectUtils.nullSafeEquals(this.key, otherCacheKey.key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -224,12 +233,27 @@ class SpringIterableConfigurationPropertySource extends SpringConfigurationPrope
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static CacheKey get(EnumerablePropertySource<?> source) {
|
|
|
|
public static CacheKey get(EnumerablePropertySource<?> source) {
|
|
|
|
|
|
|
|
if (isImmutable(source)) {
|
|
|
|
|
|
|
|
return IMMUTABLE_PROPERTY_SOURCE;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (source instanceof MapPropertySource) {
|
|
|
|
if (source instanceof MapPropertySource) {
|
|
|
|
return new CacheKey(((MapPropertySource) source).getSource().keySet());
|
|
|
|
MapPropertySource mapPropertySource = (MapPropertySource) source;
|
|
|
|
|
|
|
|
return new CacheKey(mapPropertySource.getSource().keySet());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new CacheKey(source.getPropertyNames());
|
|
|
|
return new CacheKey(source.getPropertyNames());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean isImmutable(EnumerablePropertySource<?> source) {
|
|
|
|
|
|
|
|
if (source instanceof OriginTrackedMapPropertySource) {
|
|
|
|
|
|
|
|
return ((OriginTrackedMapPropertySource) source).isImmutable();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME
|
|
|
|
|
|
|
|
.equals(source.getName())) {
|
|
|
|
|
|
|
|
return source.getSource() == System.getenv();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|