9191 */
9292public class CloudFoundryVcapEnvironmentPostProcessor implements EnvironmentPostProcessor , Ordered {
9393
94- private static final String VCAP_APPLICATION = "VCAP_APPLICATION" ;
95-
96- private static final String VCAP_SERVICES = "VCAP_SERVICES" ;
97-
9894 private final Log logger ;
9995
10096 // Before ConfigDataEnvironmentPostProcessor so values there can use these
@@ -126,12 +122,12 @@ public void postProcessEnvironment(ConfigurableEnvironment environment, SpringAp
126122 addWithPrefix (properties , getPropertiesFromApplication (environment , jsonParser ), "vcap.application." );
127123 addWithPrefix (properties , getPropertiesFromServices (environment , jsonParser ), "vcap.services." );
128124 MutablePropertySources propertySources = environment .getPropertySources ();
125+ PropertiesPropertySource vcapSource = new PropertiesPropertySource ("vcap" , properties );
129126 if (propertySources .contains (CommandLinePropertySource .COMMAND_LINE_PROPERTY_SOURCE_NAME )) {
130- propertySources .addAfter (CommandLinePropertySource .COMMAND_LINE_PROPERTY_SOURCE_NAME ,
131- new PropertiesPropertySource ("vcap" , properties ));
127+ propertySources .addAfter (CommandLinePropertySource .COMMAND_LINE_PROPERTY_SOURCE_NAME , vcapSource );
132128 }
133129 else {
134- propertySources .addFirst (new PropertiesPropertySource ( "vcap" , properties ) );
130+ propertySources .addFirst (vcapSource );
135131 }
136132 }
137133 }
@@ -146,7 +142,7 @@ private void addWithPrefix(Properties properties, Properties other, String prefi
146142 private Properties getPropertiesFromApplication (Environment environment , JsonParser parser ) {
147143 Properties properties = new Properties ();
148144 try {
149- String property = environment .getProperty (VCAP_APPLICATION , "{}" );
145+ String property = environment .getProperty (" VCAP_APPLICATION" , "{}" );
150146 Map <String , Object > map = parser .parseMap (property );
151147 extractPropertiesFromApplication (properties , map );
152148 }
@@ -159,7 +155,7 @@ private Properties getPropertiesFromApplication(Environment environment, JsonPar
159155 private Properties getPropertiesFromServices (Environment environment , JsonParser parser ) {
160156 Properties properties = new Properties ();
161157 try {
162- String property = environment .getProperty (VCAP_SERVICES , "{}" );
158+ String property = environment .getProperty (" VCAP_SERVICES" , "{}" );
163159 Map <String , Object > map = parser .parseMap (property );
164160 extractPropertiesFromServices (properties , map );
165161 }
0 commit comments