Skip to content

Improve readability of CloudFoundryVcapEnvironmentPostProcessor by removing constants #45855

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@
*/
public class CloudFoundryVcapEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {

private static final String VCAP_APPLICATION = "VCAP_APPLICATION";

private static final String VCAP_SERVICES = "VCAP_SERVICES";

private final Log logger;

// Before ConfigDataEnvironmentPostProcessor so values there can use these
Expand Down Expand Up @@ -126,12 +122,12 @@ public void postProcessEnvironment(ConfigurableEnvironment environment, SpringAp
addWithPrefix(properties, getPropertiesFromApplication(environment, jsonParser), "vcap.application.");
addWithPrefix(properties, getPropertiesFromServices(environment, jsonParser), "vcap.services.");
MutablePropertySources propertySources = environment.getPropertySources();
PropertiesPropertySource vcapSource = new PropertiesPropertySource("vcap", properties);
if (propertySources.contains(CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME)) {
propertySources.addAfter(CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME,
new PropertiesPropertySource("vcap", properties));
propertySources.addAfter(CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME, vcapSource);
}
else {
propertySources.addFirst(new PropertiesPropertySource("vcap", properties));
propertySources.addFirst(vcapSource);
}
}
}
Expand All @@ -146,7 +142,7 @@ private void addWithPrefix(Properties properties, Properties other, String prefi
private Properties getPropertiesFromApplication(Environment environment, JsonParser parser) {
Properties properties = new Properties();
try {
String property = environment.getProperty(VCAP_APPLICATION, "{}");
String property = environment.getProperty("VCAP_APPLICATION", "{}");
Map<String, Object> map = parser.parseMap(property);
extractPropertiesFromApplication(properties, map);
}
Expand All @@ -159,7 +155,7 @@ private Properties getPropertiesFromApplication(Environment environment, JsonPar
private Properties getPropertiesFromServices(Environment environment, JsonParser parser) {
Properties properties = new Properties();
try {
String property = environment.getProperty(VCAP_SERVICES, "{}");
String property = environment.getProperty("VCAP_SERVICES", "{}");
Map<String, Object> map = parser.parseMap(property);
extractPropertiesFromServices(properties, map);
}
Expand Down
Loading