spring-cloud-consul icon indicating copy to clipboard operation
spring-cloud-consul copied to clipboard

Update misleading config watch documentation.

Open jkstrauss opened this issue 6 years ago • 5 comments

@ConstructorBinding annotated classes not refreshing I am using Spring Cloud version Hoxton with Spring Boot 2.2.x

Spring Boot 2.2.x introduced a an annotation @ConstructorBinding that allows defining @ConfigurationProperties classes strictly through constructors, which allows using immutable classes in configurations.

While the initial configuration is being loaded from my Consul K/V server, subsequent changes to the server do not get reflected in the configuration objects. The problem is not mitigated by using @RefreshScope.

jkstrauss avatar Feb 17 '20 18:02 jkstrauss

Immutable classes are just that and are not refreshable

spencergibb avatar Feb 17 '20 18:02 spencergibb

@spencergibb I understand that the actual configuration object would not change; it is immutable. What I was expecting is that the application context would refresh, so that, for example, new HTTP requests would get a new configuration object that would reflect the new consul configuration.

The following line from the docs is what led me to believe that this would happen:

Configuration is currently read on startup of the application. Sending a HTTP POST to /refresh will cause the configuration to be reloaded. Config Watch will also automatically detect changes and reload the application context.

(https://cloud.spring.io/spring-cloud-consul/reference/html/#spring-cloud-consul-config-watch)

I tried manually refreshing the application with the /refresh endpoint, but I get the same results.

jkstrauss avatar Feb 18 '20 14:02 jkstrauss

Refresh triggers configuration property rebinding and clears the refresh scope cache. So that statement isn't quite right

spencergibb avatar Feb 18 '20 15:02 spencergibb

@spencergibb Please elaborate. Which statement are you referring to?

jkstrauss avatar Feb 18 '20 16:02 jkstrauss

and reload the application context.

It doesn't actually reload the application context.

spencergibb avatar Feb 18 '20 16:02 spencergibb