Update `EnvironmentPostProcessorApplicationListener` so that it can
either use values from `spring.factories` or use a factory interface.
Closes gh-22529
Add support for volume mounted directories where the filename becomes
the property key and the file contents becomes the value.
Support is provided via a dedicated `VolumeMountDirectoryPropertySource`
class which can either be used directly, or via a "volumemount:/..."
`spring.config.import` location.
Closes gh-19990
Co-authored-by: Phillip Webb <pwebb@vmware.com>
Deprecate `ConfigFileApplicationListener` and provide a replacement
mechanism that supports arbitrary config data imports.
This commit updates the following areas:
- Extract `EnvironmentPostProcessor` invocation logic from the
`ConfigFileApplicationListener` to new dedicated listener. Also
providing support for `Log` injection.
- Extract `RandomPropertySource` adding logic from the
`ConfigFileApplicationListener` to a dedicated class.
- Migrate to the recently introduced `DefaultPropertiesPropertySource`
class when moving the defaultProperties `PropertySource`
- Replace processing logic with a phased approach to ensure that
profile enablement happens in a distinct phase and that profiles
can no longer be activated on an ad-hoc basis.
- Provide a more predictable and logical import order for processing
`application.properties` and `application.yml` files.
- Add support for a `spring.config.import` property which can be used
to import additional config data. Also provide a pluggable API
allowing third-parties to resolve and load locations themselves.
- Add `spring.config.activate.on-profile` support which replaces the
existing `spring.profiles` property.
- Add `spring.config.activate.on-cloud-platform` support which allows
a config data document to be active only on a given cloud platform.
- Support a `spring.config.use-legacy-processing` property allowing the
previous processing logic to be used.
Closes gh-22497
Co-authored-by: Madhura Bhave <mbhave@vmware.com>
Update `CloudPlatform` with a new `isEnforced` method that's backed
by a `Binder` rather than the `Environment`. We'll require this when
we overhaul our external config data processing logic.
Closes gh-22498
Extract `DefaultPropertiesPropertySource` from `SpringApplication` so
that logic can be easily accessed by other classes. Specifically the
property source name and logic to move the source to the end of the
list needs to be called from several places.
Closes gh-22520
Add a new `DeferredLogFactory` interface and `DeferredLogs`
implementation that can be used when a `DeferredLog` instance is needed
but the `switchOver` method should be handled elsewhere.
This interface has primarily been added so `EnvironmentPostProcessor`
classes will no longer need to implement `ApplicationEventListener`
just to switch over their logs.
Closes gh-22496
Update `OriginTrackedPropertiesLoader` so that it can support
multi-document properties files. These are similar to multi-document
YAML files but use `#---` as the separator.
Closes gh-22495
Co-authored-by: Phillip Webb <pwebb@vmware.com>
Update `OriginTrackedYamlLoader` so that empty documents are filtered
from the result. Prior to this commit, our origin wrapper would confuse
the YAML processor and cause empty documents to be included in the Map
with a key of "document" and no value.
Closes gh-22493
Update value object binder support so that parameters can be annotated
with `@Name` if a specific property name should be used. Prior to this
commit is was not possible to use Java reserved words as property names.
Closes gh-22492
Prior to this commit, the application availability infrastructure
would mix the `AvailabilityState`, the `HealthIndicator` and the
`HealthGroup` concepts and would not align with the rest.
This commit auto-configures the livenessState and readinessState
health indicators with the relevant configuration properties.
Unlike other indicators, they are not enabled by default but might
be in future versions.
This also moves the `management.health.probes.enabled` property
to `management.endpoint.health.probes.enabled` since "probes" here
is not a health indicator but rather a configuration flag for the
health endpoint.
Finally, the probes auto-configuration is refined to automatically
add liveness and readiness indicators for the probes group if
they're not already present.
Closes gh-22107
BackgroundPreinitializer is not relevant in native images so it is
better to ignore it automatically in order to reduce the footprint
in such environment.
See gh-22392
This commit adds a check to the support code for the Gradle plugin
bootBuildImage task to ensure that the jar file that will be passed
to a builder is readable and has a valid directory. This prevents a
situation where the jar file cannot be read because it is prepended
with a launch script, and the builder does not receive any files to
process.
Notes have also been added to the Gradle plugin documentation to warn
against using a bootJar launchScript configuration and bootBuildImage
together, as well as caveats about launchScript that match the Maven
plugin documentation.
Fixes gh-22223
Prior to this commit, OnClassCondition started a thread even if the number of
passed autoconfiguration class candidates never exceeded 1. This commit only
starts a thread if there is actually work to split in half.
See gh-22294
Previously, regular bean definitions for configuration properties classes
that attempt to use constructor binding were detected in a bean factory
post-processor, ConfigurationPropertiesBeanDefinitionValidator. This
validation examined every standard bean definition and failed if it
encountered one for a class that should have used constructor binding.
There were two downsides to this approach:
1. Reflection used to identify if the bean should be using constructor
binding triggered class loading that could prevent subsequent
instrumentation by a load-time weaver.
2. The cost of the validation was incurred when there was no
misconfiguration to report.
This commit replaces ConfigurationPropertiesBeanDefinitionValidator
with a failure analyzer. This failure analyzer only runs once a failure
has occurred and the application context is not going to complete
refresh. This avoids causing problems with subsequent instrumentation
and also avoids the cost of validation and error reporting unless there
is an error.
Fixes gh-20798
As of Spring Framework 5.3, it is now possible to use `PathPatternParser`
to parse and match request mapping path patterns, as an alternative to
the current default `AntPathMatcher`.
This new implementation has been used for a while in Spring WebFlux and
it’s been designed for consistency and performance.
This commit introduces a new configuration property for opting-in this
new variant:
`spring.mvc.pathmatch.matching-strategy=path_pattern_parser`
The default option is still `ant_path_matcher` for now, but we might
change the default in future versions since Spring Framework considers
it the best choice for modern applications.
There are several behavior differences with this new variant:
* double wildcards `"**"` are rejected when used in the middle patterns,
this is only allowed as the last matching segment in a pattern.
* it is incompatible with some path matching options, like
suffix-pattern, registered-suffix-pattern or configuring a Servlet
prefix on the `DispatcherServlet` (`spring.mvc.servlet.path=/test`)
This commit introduces two `FailureAnalyzer` implementations to guide
developers when facing those issues.
Closes gh-21694
This commit upgrade to Infinispan 11.0.1.Final and update dependency
management to use the bom now that it declares all the modules that
the project ships. See gh-19791
Closes gh-22286
Previously, the tests used absolute values to verify that the work
had completed sufficiently quickly. This led to flaky tests in
environments where the performance can be variable such as CI.
This commit tries to make the tests more robust by comparing the
performance to a baseline and requiring it to be twice as fast.
Closes gh-22137
Previously, spring-boot-docs used the java-base-plugin and then added
configuration on top. This has proven to be error prone, with the most
recent problem being that the tests were not being compiled and run.
This commit changes approach and applies the java plugin to the project
instead of the java-base plugin. Now, rather than adding the necessary
configuration to the base, the unwanted pieces of the java plugin's
configuration – specifically the jar and javadoc tasks – are disabled
instead. The DeployedPlugin has also been updated so that it does not
create a publication from the java component for projects that have a
disabled jar task.
Closes gh-22284
This commit improves the validation of URLs provided in the property
'spring.redis.url' used to auto-configure a Spring Data Redis
connection. In particular, only the URL schemes 'redis://' and
'rediss://' are allowed, and any other scheme will result in a
configuration error. A failure analyzer is also provided to improve
diagnostics for common mis-configurations detected by this validation.
Fixes gh-21999
Previously, the import selector for `@ImportAutoConfiguration` did not
consider the spring.autoconfigure.exclude property when determining
which auto-configurations to exclude. This meant that tests using a
slice that included a particular auto-configuration would include it
even if the application's configuration excluded it via
spring.autoconfigure.exclude. Confusingly, this could result in a
sliced test using an auto-configuration that would be excluded in a
broader `@SpringBootTest`.
This commit updates the ImportAutoConfigurationImportSelector to
consider the spring.autoconfigure.exclude property so that sliced tests
will use a subset of the auto-configurations that a `@SpringBootTest`
would use.
Fixes gh-21736
Since Spring Framework 4.3.0.RC2, a default embedded value resolver
has been registered with the bean factory when one is not otherwise
configured. This meant that placeholders in `@Value` would be resolved
with or without PropertyPlaceholderAutoConfiguration defining a
PropertySourcesPlaceholderConfigurer bean. However, placeholders in
bean definitions would only be resolved if a
PropertySourcesPlaceholderConfigurer was defined.
This commit updates PropertyPlaceholderAutoConfigurationTests to align
with this change in Framework. We now test that placeholders are
resolved in `@Value` annotations with or without the auto-configuration
and that placeholders in bean definitions are only resolved with the
auto-configured.
Closes gh-22230
Prior to this commit, configuring a reactive Elasticsearch client would
auto-configure an Actuator Health check using a synchronous client, with
the default configuration properties (so tarting localhost:9200).
This would lead to false reports of unhealthy Elasticsearch clusters
when using reactive clients.
This commit reproduces the logic for MongoDB repositories: if a reactive
variant is available, it is selected for the health check
infrastructure.
See gh-21042