Spring Boot keeps a list of ConfigDataResources and will call contains on the list to determine whether it should load the resource. Our hashcode and equals methods were using variables in ConfigServerConfigDataResource which had no bearing on the configuration that would be loaded, so this change simplifies this to make sure two ConfigServerConnfigDataResources would be considered equal if they would end up making the same request to the config server for configuration.
Co-authored-by: Ryan Baxter <524254+ryanjbaxter@users.noreply.github.com>
* Use ConfigClientProperties if it exists in the BootstrapContext before creating a new one. Fixes #1919
* Add back test, have one test use uri from properties
in application-<profile>.{properties|yaml}
spring.config.import=configserver:http://configserver.example.com?fail-fast=true&max-attempts=10&max-interval=1500&multiplier=1.2&initial-interval=1100"
This required that the RetryTemplate be created as late as possible and it is no longer put in the bootstrap context. A RetryTemplateFactory was created so the LoaderInterceptor and the ConfigServerInstanceProvider can create a RetryTemplate. ConfigServerConfigDataLocationResolver creates RetryProperties from the url parameters if they are provided.
ConfigServerConfigDataLoader now creates a ConfigClientFailFastException and registers it in the application context rather and returns an empty ConfigData rather than throwing and exception. Then in ConfigClientAutoConfiguration an ApplicationStartedEvent is listened for and if the fail fast exception is there, throws it halting execution. This all allows logging in ConfigData to show.
Fixes gh-1797
Previously the resource name and location needed to be parsed. This change updates NativeEnvironmentRepository to pass a ConfigDataEnvironmentUpdateListener to ConfigDataEnvironmentPostProcessor.applyTo() and match PropertySources to location and resource. PassthruEnvironmentRepository is updated to attach the original PropertySource to use later in the clean() method to retrieve the location and resource avoiding parsing.
Fixes gh-1875
Previously a local profiles specific file would have more priority than a remote profile specific file. Using a new ConfigData Option, this is now fixed.
Fixes gh-1795
Adds ConfigServerConfigDataMissingEnvironmentPostProcessor that checks if there is a spring.config.import=configserver: statement. If not, an exception is thrown and a FailureAnalyzer provides hints to fix the issue.
Fixes gh-1813
In ConfigData, the Profiles object takes care of resolving the default profile. So only prefer spring.cloud.config.profiles if it has been set to something other than 'default'.
Fixes gh-1777
* Uses BindHandler if registered in bootstrap.
This allows spring-cloud-context to register a TextEncryptorBindHandler and handle `{cipher}` prefixed properties prior to sending for remote data.
* Adds test that a BindHandler in bootstrap context is used.
* Makes KeyProperties a bean that is conditional on missing.
The root exception can detail an important root cause. For
example with native-images it can indicate a flag you need
to set for the native-image to compile correctly:
Caused by: java.net.MalformedURLException:
Accessing an URL protocol that was not enabled. The URL
protocol http is supported but not enabled by default.
It must be enabled by adding the -H:EnableURLProtocols=http
option to the native-image command.