Description:

We have a profile property to connect to cloud config.(spring.cloud.config.profile) with spring-cloud-config-client-4.0.4.jar, in class ConfigServicePropertySourceLocator, there is a new method which combines profile from property and environment with comma separated. So, finally profile value while connecting to cloud config will be like below and failing cloud config call.

HTTP GET https://XXXXXXXXXX/cloud-config/properties///

Even though profile properties are overrider at line 122 ConfigClientProperties properties = this.defaultProperties.override(environment);

in the next line, profile value is getting updated by appending with all the profiles properties.setProfile(String.join(",", combineProfiles(properties, environment)));

So in method getRemoteEnvironment, while preparing the URL, profile path param is goign as comma separated and there by causing issue.

Comment From: ryanjbaxter

Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

Comment From: adityakiranpendyala

Hi @ryanjbaxter ,

I am preparing a sample with out exposing specific details. But issue gist is,

1.Spring allows multiple profiles

2.At line 116, properties.setProfile(String.join(",", combineProfiles(properties, environment))); profile can be comma separated.

3.And we are sending this profile as a path parameter to a GET call at line 291 response = restTemplate.exchange(uri + path, HttpMethod.GET, entity, Environment.class, args);

where args is either = new String[] { name, profile }; or new String[] { name, profile, label };

So, we are ending up having a comma separated URL in a Http GET call

FILE: ConfigServicePropertySourceLocator.java

Comment From: adityakiranpendyala

Hi @ryanjbaxter ,

Here is an example. You can run below project as a Spring Boot application.

  1. I have one profile defined for logging.("logging-profile")
  2. I have properties to connect to spring cloud to download properties on startup.(config profile="CONFIG_PROFILE") So, I have two profiles, one at environment level and one for cloud profile.

spring.cloud.config: name: CONFIG_NAME uri: http://localhost:8000/properties label: CONFIG_LABEL profile: CONFIG_PROFILE enabled: false failFast: true

Now when I am starting application, I am getting URL as profiles with comma separated and failing. demo.zip

GET request for "http://localhost:8888/CONFIG_NAME/CONFIG_PROFILE,logging-profile/CONFIG_LABEL

Comment From: ryanjbaxter

I think I understand what you are saying now...

If you set spring.cloud.config.profile it should override any profile(s) set in any other manor. So in your example if you set spring.cloud.config.profile=CONFIG_LABEL and set spring.profiles.active=logging-profile the request made to the config server should only have the CONFIG_LABEL profile, ie http://localhost:8888/CONFIG_NAME/CONFIG_PROFILE/CONFIG_LABEL. Is that correct?

Comment From: adityakiranpendyala

yes @ryanjbaxter , your understanding is correct. Config Service URL should be http://localhost:8888/CONFIG_NAME/CONFIG_PROFILE/CONFIG_LABEL but now it is preparing as http://localhost:8888/CONFIG_NAME/CONFIG_PROFILE,logging-profile/CONFIG_LABEL