Multiple Requests at Config Server after Restart

381 views Asked by At

After a POST to restart on the cloud config client, a new ConfigServicePropertySourceLocator is created and the old ones are kept. The problem is, they are all invoked after restart, so if I POST to restart 10 times, I get 11 beans and 11 invocations, which results in 11 GET calls to the config server.

Breakpoint at SpringApplication#addInitializers(ApplicationContextInitializer<?>... initializers)

this = {SpringApplication@2244} 
initializers = {ApplicationContextInitializer[2]@6093} 
 0 = {PropertySourceBootstrapConfiguration$$EnhancerBySpringCGLIB$$56dce074@6097} 
 1 = {EnvironmentDecryptApplicationInitializer@6098} 
this.initializers = {ArrayList@3671}  size = 10
 0 = {DelegatingApplicationContextInitializer@3784} 
 1 = {ContextIdApplicationContextInitializer@3785} 
 2 = {ConfigurationWarningsApplicationContextInitializer@3786} 
 3 = {ServerPortInfoApplicationContextInitializer@3787} 
 4 = {SharedMetadataReaderFactoryContextInitializer@3788} 
 5 = {AutoConfigurationReportLoggingInitializer@3789} 
 6 = {BootstrapApplicationListener$AncestorInitializer@3678} 
 7 = {PropertySourceBootstrapConfiguration$$EnhancerBySpringCGLIB$$56dce074@3705} 
 8 = {EnvironmentDecryptApplicationInitializer@3706} 
 9 = {BootstrapApplicationListener$DelegatingEnvironmentDecryptApplicationInitializer@3715} 

As you can see, it is about to add another instance of PropertySourceBootstrapConfiguration to the initializer list.

What could be causing this and how can I avoid it?

1

There are 1 answers

1
Josh Miller On BEST ANSWER

This appears to be a known issue - there's a bug logged for it on GitHub at: https://github.com/spring-cloud/spring-cloud-commons/issues/138 - there's a project created to reproduce the issue (https://github.com/nicolaferraro/spring-cloud-context-example) and it seems to be something that is fairly common.