Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround Pivotal Spring Cloud Services bug consuming and discarding EnumerablePropertySources from the Environment #21

Closed
jxblum opened this issue Jan 28, 2019 · 1 comment
Assignees
Milestone

Comments

@jxblum
Copy link
Contributor

jxblum commented Jan 28, 2019

When the org.springframework.cloud:spring-cloud-services-starter-service-registry dependency is added to the CLASSPATH of a Spring Boot application (and specifically, a Spring Boot for Pivotal GemFire (SBDG) application, i.e. org.springframework.geode:spring-gemfire-starter), Pivotal Spring Cloud Services will create a "bootstrap" ApplicationContext with a "bootstrap" Environment.

During the creation of this "bootstrap" ApplicationContext and Environment, specific property sets (aka PropertySources) are copied from the "main" ApplicationContext, Environment object to the "bootstrap" Environment. And, in this particular case, the boot.data.gemfire.cloudcache configuration ProperySource is copied from "main" to "bootstrap". This custom SBDG specific PropertySource contains essential information from the environment/context in which the SBDG app is deploy (e.g. PCF when using PCC). 1 such piece of pertinent information is Authentication credentials extracted from the VCAP environment variables to allow a Spring Boot, Pivotal GemFire cache client application to authenticate with the bound PCC cluster when deployed to PCF.

However, Pivotal Spring Cloud Services is very specific about which PropertySources it collects from the "main" Environment to include in the "bootstrap" Environment. It specifically collects EnumerablePropertySources and later discards them, which then prevents the Spring Boot, Pivotal GemFire cache client application from successfully authenticating with the bound PCC cluster when deployed to PCF.

This enhancement works around this Pivotal Spring Cloud Services behavior (bug?).

@jxblum jxblum self-assigned this Jan 28, 2019
@jxblum jxblum added this to the 1.0.0.M4 milestone Jan 28, 2019
jxblum added a commit to jxblum/spring-boot-data-geode that referenced this issue Jan 29, 2019
@jxblum jxblum closed this as completed in 7f2a9eb Jan 29, 2019
dsyer pushed a commit to dsyer/spring-boot-data-geode that referenced this issue Feb 7, 2019
Normally in the `Environment` it is better to let user-defined
properties take precedence, rather than trying to simply omit
them. This change makes the `ClientSecurityAutoConfiguration` rely
on that existing feature, rather than trying to inspect the property
sources manually and add guess which properties are set.

See spring-projects#21
@dsyer
Copy link
Member

dsyer commented Feb 7, 2019

In #22 I show a better way to fix this issue using the existing contract of Environment and the precedence of PropertySources it defines. Feel free to adapt it, or ignore it if your prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants