jamesfredley commented on code in PR #16547:
URL: https://github.com/apache/grails-core/pull/16547#discussion_r4210586848


##########
grails-core/src/main/groovy/org/grails/config/yaml/YamlPropertySourceLoader.java:
##########
@@ -58,9 +61,17 @@ public List<PropertySource<?>> load(String name, Resource 
resource) throws IOExc
 
     public List<PropertySource<?>> load(String name, Resource resource, 
List<String> filteredKeys) throws IOException {
         setResources(resource);
+        // Select source documents once; merging resolved configuration must 
not re-evaluate JVM profiles.
+        final List<String> activeProfiles = Arrays.asList(
+                
StringUtils.tokenizeToStringArray(System.getProperty("spring.profiles.active", 
""), ","));
         setDocumentMatchers((DocumentMatcher) properties -> {
-            final String profile = properties.getProperty("spring.profiles");
-            return profile == null || 
profile.equalsIgnoreCase(System.getProperty("spring.profiles.active")) ? 
MatchStatus.FOUND : MatchStatus.NOT_FOUND;
+            final String profile = 
properties.getProperty("spring.config.activate.on-profile", "").trim();

Review Comment:
   A sequence such as `spring.config.activate.on-profile: [alpha, beta]` is 
flattened to `spring.config.activate.on-profile[0]` and `[1]`. This lookup asks 
for the unindexed name, receives the default empty string, and treats the 
document as unrestricted. With only `gamma` active the inactive document is 
still merged, including YAML loaded through `grails.config.locations`.
   
   Read the indexed selector values and evaluate them before treating a missing 
unindexed key as "always on". The new whitespace rows do not cover a sequence. 
The same gap applies to a sequence-valued `spring.profiles`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to