support spring-cloud-context config refreshing
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
feature request / enhancement.
spring cloud supports runtime config property refreshing. this is not limited to config properties defined by a spring cloud config repository but also refreshes changes to application-external .properties/.yml files (and all other property sources like system props, env vars, etc.).
ref. http://cloud.spring.io/spring-cloud-static/Camden.SR7/#_refresh_scope
after refreshing the config, the spring environment reflects the changes, but `grailsApplication.config.getProperty(...)` does not.
(i think the grails config propertySource is not updated when the spring cloud `ConfigRefresher` is triggered - https://github.com/spring-cloud/spring-cloud-commons/blob/v1.1.9.RELEASE/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ContextRefresher.java).
would be great if grails would support config refreshing this way because it does not require an application restart.
### Task List
- [x] Steps to reproduce provided
- [ ] Stacktrace (if present) provided
- [ ] Example that reproduces the problem uploaded to Github
- [x] Full description of the issue provided (see below)
### Steps to Reproduce
1. grails create-app `myapp` or http://start.grails.org with defaults
2. `build.gradle`
- add `mavenBom "org.springframework.cloud:spring-cloud-dependencies:Camden.SR7'`
- add `compile "org.springframework.cloud:spring-cloud-starter-config"`
(ref. http://projects.spring.io/spring-cloud)
3. add an `application.yml` into the app root directory (external config file)
```yml
foo:
bar: foobar!
```
4. `grails run-app` / `gradlew bootRun`
5. verify property value
```groovy
assert grailsApplication.mainContext.environment.getProperty("foo.bar") == "foobar!"
assert grailsApplication.config.getProperty("foo.bar") == "foobar!"
```
6. change external config file (`myapp/application.yml`)
```yml
foo:
bar: foobar2
```
7. `POST http:localhost:8080/refresh`
### Expected Behaviour
```groovy
assert grailsApplication.mainContext.environment.getProperty("foo.bar") == "foobar2"
assert grailsApplication.config.getProperty("foo.bar") == "foobar2"
```
both assertions should pass
### Actual Behaviour
- spring environment property lookup assertion passes
- grails config property lookup fails (still old value `foobar!`)
### Environment Information
- **Operating System**: win x64
- **Grails Version:** 3.2.11
- **JDK Version:** oracle 8u131
- **Container Version (If Applicable):** embedded
### Example Application
- n/a (i can come up with one if required)
Contributor guide
Research direction
Reproduce the behavior using build.gradle with the Spring Cloud Config dependency, the external application.yml, and POST /refresh. Start by tracing how the Spring Cloud ContextRefresher updates the environment versus grailsApplication.config. Done means both property lookups return the changed value after refresh without restarting the application.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy, spring
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100