weinellucian opened a new issue, #15840:
URL: https://github.com/apache/grails-core/issues/15840
### Expected Behavior
We are encountering an issue with Holders.config.merge() in Grails 7.1.0
when multiple Grails applications are deployed on the same Apache Tomcat
10.1.50 instance.
The problem does not occur when only a single Grails application is
deployed. The same code has been working reliably in Grails 6.x without any
issues.
Environment
**Use Case**
Our application has a scheduled CRON job that periodically reloads
application-specific configuration values from a database.
The reload process is designed to preserve the original application
configuration and then merge it back after refreshing dynamic configuration
values.
The workflow is:
1. Back up the original configuration (initialConfig) that contains values
loaded from:
- application.groovy / application.yml
- External filesystem configuration
- Other startup configuration sources
2. Clear the current configuration using:
- Holders.config.clear()
3.Restore the original configuration using:
Holders.config.merge(initialConfig)
**Expected Behavior:**
After calling: **Holders.config.merge(initialConfig)** all configuration
entries stored in **initialConfig** should be restored into Holders.config.
This behavior works correctly: in In Grails 6.x, whereas in Grails 7.1.0 it
works when only a single application is deployed in Tomcat
if we deploy more than one Grails 7.1.0 **Holders.config.merge** does not
correctly restore the configuration.
Instead, the application configuration appears to be lost or emptied,
leaving **Holders.config** in an invalid state. As a result, application
functionality dependent on configuration values ant it stops working
**Configuration Reload Logic**
static PropertySourcesConfig initialConfig = new PropertySourcesConfig()
backupInitialConfiguration()
Holders.config.clear()
// In Grails 7.1.0, when multiple applications are deployed in the same
// Tomcat instance, this call does not restore the configuration correctly.
Holders.config.merge(initialConfig)
//Backup Logic
public void backupInitialConfiguration() {
if (initialConfig?.size() == 0) {
Config config = Holders.config
Map<Object, Object> configMap = [:]
for (def entry : config) {
configMap.put(entry.key, config.get(entry.key))
}
initialConfig = new PropertySourcesConfig(configMap)
}
}
### Actual Behaviour
Mentioned in above section
### Steps To Reproduce
It's mentioned in "Expected Behavior" Section
### Environment Information
Grails Version: 7.1.0
Tomcat Version: 10.1.50
Deployment Model: Multiple Grails applications deployed in the same Tomcat
instance
Java Version: JDK 17 and Above
### Example Application
_No response_
### Version
7.1.0
--
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]