diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/EnvironmentEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/EnvironmentEndpoint.java index e508cc3fe8..e0c922bce5 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/EnvironmentEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/EnvironmentEndpoint.java @@ -16,12 +16,9 @@ package org.springframework.boot.actuate.endpoint; -import java.lang.reflect.Field; -import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; -import java.util.Set; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.EnvironmentAware; @@ -32,7 +29,6 @@ import org.springframework.core.env.Environment; import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; import org.springframework.core.env.StandardEnvironment; -import org.springframework.util.ReflectionUtils; /** * {@link Endpoint} to expose {@link ConfigurableEnvironment environment} information. @@ -98,8 +94,8 @@ public class EnvironmentEndpoint extends AbstractEndpoint> i private void extract(String root, Map> map, PropertySource source) { if (source instanceof CompositePropertySource) { - Set> nested = getNestedPropertySources((CompositePropertySource) source); - for (PropertySource nest : nested) { + for (PropertySource nest : ((CompositePropertySource) source) + .getPropertySources()) { extract(source.getName() + ":", map, nest); } } @@ -108,19 +104,6 @@ public class EnvironmentEndpoint extends AbstractEndpoint> i } } - @SuppressWarnings("unchecked") - private Set> getNestedPropertySources(CompositePropertySource source) { - try { - Field field = ReflectionUtils.findField(CompositePropertySource.class, - "propertySources"); - field.setAccessible(true); - return (Set>) field.get(source); - } - catch (Exception ex) { - return Collections.emptySet(); - } - } - public Object sanitize(String name, Object object) { return this.sanitizer.sanitize(name, object); } diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java b/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java index 9042f08cd5..07307ecc4e 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java @@ -16,7 +16,6 @@ package org.springframework.boot.bind; -import java.lang.reflect.Field; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -32,7 +31,6 @@ import org.springframework.core.env.PropertySource; import org.springframework.core.env.PropertySources; import org.springframework.core.env.PropertySourcesPropertyResolver; import org.springframework.core.env.StandardEnvironment; -import org.springframework.util.ReflectionUtils; import org.springframework.validation.DataBinder; /** @@ -142,27 +140,11 @@ public class PropertySourcesPropertyValues implements PropertyValues { private void processCompositePropertySource(CompositePropertySource source, PropertySourcesPropertyResolver resolver, PropertyNamePatternsMatcher includes, Collection exacts) { - for (PropertySource nested : extractSources(source)) { + for (PropertySource nested : source.getPropertySources()) { processPropertySource(nested, resolver, includes, exacts); } } - private Collection> extractSources(CompositePropertySource composite) { - Field field = ReflectionUtils.findField(CompositePropertySource.class, - "propertySources"); - field.setAccessible(true); - try { - @SuppressWarnings("unchecked") - Collection> collection = (Collection>) field - .get(composite); - return collection; - } - catch (Exception ex) { - throw new IllegalStateException( - "Cannot extract property sources from composite", ex); - } - } - private void processDefaultPropertySource(PropertySource source, PropertySourcesPropertyResolver resolver, PropertyNamePatternsMatcher includes, Collection exacts) {