diff --git a/spring-geode/src/main/java/org/springframework/geode/core/env/VcapPropertySource.java b/spring-geode/src/main/java/org/springframework/geode/core/env/VcapPropertySource.java index a1f4b26f..c61b128c 100644 --- a/spring-geode/src/main/java/org/springframework/geode/core/env/VcapPropertySource.java +++ b/spring-geode/src/main/java/org/springframework/geode/core/env/VcapPropertySource.java @@ -97,8 +97,9 @@ public class VcapPropertySource extends PropertySource env instanceof ConfigurableEnvironment) - .map(env -> ((ConfigurableEnvironment) env).getPropertySources()) + .filter(ConfigurableEnvironment.class::isInstance) + .map(ConfigurableEnvironment.class::cast) + .map(ConfigurableEnvironment::getPropertySources) .map(propertySources -> propertySources.get(VCAP_PROPERTY_SOURCE_NAME)) .map(VcapPropertySource::from) .orElseThrow(() -> newIllegalArgumentException( @@ -119,15 +120,25 @@ public class VcapPropertySource extends PropertySource VCAP_PROPERTY_SOURCE_NAME.equals(it.getName())) - .filter(it -> it instanceof EnumerablePropertySource) .filter(VCAP_REQUIRED_PROPERTIES_PREDICATE) - .map(it -> (EnumerablePropertySource) it) + .filter(EnumerablePropertySource.class::isInstance) + .map(EnumerablePropertySource.class::cast) .map(VcapPropertySource::new) .orElseThrow(() -> newIllegalArgumentException( - "A valid EnumerablePropertySource named [%s] with VCAP properties is required", + "A valid EnumerablePropertySource named [%s] containing VCAP properties is required", VCAP_PROPERTY_SOURCE_NAME)); } + /** + * Constructs a new {@link PropertySource} from the existing, required {@link EnumerablePropertySource} instance + * with the default name, {@literal boot.data.gemfire.vcap}, containing the {@literal VCAP} environment variable + * configuration. + * + * @param propertySource existing, required {@link EnumerablePropertySource} containing the {@literal VCAP} + * environment variables. + * @throws IllegalArgumentException if the {@literal EnumerablePropertySource} is {@literal null}. + * @see org.springframework.core.env.EnumerablePropertySource + */ private VcapPropertySource(EnumerablePropertySource propertySource) { super(THIS_PROPERTY_SOURCE_NAME, propertySource); } @@ -218,7 +229,11 @@ public class VcapPropertySource extends PropertySource