codeconsole opened a new issue, #16766:
URL: https://github.com/apache/grails-core/issues/16766

   ### Expected Behavior
   
   A key with a dot in a map of `application.groovy` and the same name set in 
dot notation by `application.yml`, a profile or the command line are one 
configuration entry, as they are one property to Spring Boot. The 
higher-precedence value is read however the configuration is read.
   
   ### Actual Behaviour
   
   `application.groovy` is merged as it is written, so `logging.level = 
['org.hibernate.SQL': 'debug']` makes the block `logging.level` hold the key 
`org.hibernate.SQL`. A dotted name from `application.yml` is merged as a path, 
so `logging.level.org.hibernate.SQL: info` makes the same block hold `org` -> 
`hibernate` -> `SQL`. The configuration then holds both:
   
   - `getProperty('logging.level.org.hibernate.SQL')` reads the flat key, which 
holds the value merged last, and is right.
   - `config.navigate('logging', 'level')`, `config.logging.level` and anything 
that iterates the block see both forms, and 
`config.logging.level.get('org.hibernate.SQL')` reads the other value whichever 
source has the higher precedence.
   
   Spring Boot binding is not affected, since the environment reads the 
original property sources. Code that reads such a block as a map is, for 
example a plugin that hands `grails.mail.props` to JavaMail as a map of 
`mail.smtp.*` keys.
   
   The base of #16732 (9.0.x before it) and Grails 8 behave the same.
   
   ### Steps To Reproduce
   
   ```groovy
   import org.grails.config.NavigableMap
   
   NavigableMap groovyConfig = new NavigableMap()
   groovyConfig.merge([logging: [level: ['org.hibernate.SQL': 'debug']]])   // 
as application.groovy is merged
   NavigableMap yaml = new NavigableMap()
   yaml.merge(['logging.level.org.hibernate.SQL': 'info'], true)            // 
as application.yml is merged
   
   NavigableMap config = new NavigableMap()
   config.merge(groovyConfig, false)                                        // 
as PropertySourcesConfig merges each source
   config.merge(yaml, false)
   
   config.getProperty('logging.level.org.hibernate.SQL')   // 'info'
   config.navigate('logging', 'level')                     // 
['org.hibernate.SQL': 'debug', org: [hibernate: [SQL: 'info']]]
   config.logging.level.get('org.hibernate.SQL')           // 'debug'
   ```
   
   ### Notes
   
   A fix has to decide which form an entry takes when both are written, and 
apply it to parsed merges, to the raw merge `PropertySourcesConfig` makes of 
each property source, and to reads through a nested map. A key written with a 
dot has to stay one key, since plugins read maps such as `grails.mail.props` by 
those keys.
   
   #16732 tried writing a dotted name into a key with a dot that a block 
already holds and reverted it (792e752e00): it covered parsed merges only, so 
`application.yml`, which `PropertySourcesConfig` merges raw, was not helped, 
and reads through a nested map did not see what it wrote. The case was left out 
of #16732, and of #16130 on 8.1.x, since it predates both.
   
   ### Environment Information
   
   9.0.x and 8.1.x, any JDK.
   
   ### Version
   
   9.0.x
   


-- 
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