This commit also makes sure to generate unique embedded data source and
disable datasource initialization as this is not required by those
tests.
See gh-9889
This commit adds an additional class check to AopAutoConfiguration as
it is main role is to configure `@EnableAspectJAutoProxy` which won't
work properly if `aspectjweaver` is not present.
Closes gh-9880
Previously, background preinitialization was started in response to
an ApplicationEnvironmentPreparedEvent and would complete at an
undetermined time later. This opened a window where SpringApplication
run could return and background preinitialization could still be
in progress. If, within this window, something attempted to configure
the logging system, an IO failure could occur as logging on the
background preinitialization thread would attempt to use resources
that had been closed.
This commit updates BackgroundPreinitializer so that it waits for
preinitialization to have completed when it receives an application
ready or application failed event. This prevents SpringApplication
run from returning while preinitialization is still in progress,
closing the window described above.
With info level logging enabled it appears that background
preinitialization consistently completes before the application ready
event is published. As a result, waiting should have no adverse effect
on performance in normal circumstances. With logging configured such
that background preinitialization outputs a large volume of log
messages (enabling trace logging for the root logger, for example), it
will be slowed down sufficiently for waiting to be necessary.
Closes gh-5669
Background preinitialization triggers static initialization of a
number of components that are slow to initialize. As the
initialization is static, it's only necessary once per class loader.
Previously, a new background preinitialization thread would be
created and started for each ApplicationEnvironmentPreparedEvent.
This commit updates the preinitializer to only create and start the
thread if preinitialization has not already been started for the
current class loader.
Closes gh-9869
Rename `ApplicationContextTester` and related classes to
`ApplicationContextRunner` and refactor existing tests to use correctly
named variables.
See gh-9875
This commit resets the artificial use of the http driver now the bolt
driver doesn't check if the connection to the Neo4J server is valid
on startup.
See neo4j/neo4j-java-driver#380
Closes gh-9500
Update `@ImportAutoConfiguration` so that it is no longer annotated with
`@AutoConfigurationPackage` and as such isn't a marker for
`AutoConfigurationPackages`.
Having `@ImportAutoConfiguration` marked as an auto-configuration
package is particularly problematic in tests since it frequently breaks
context caching.
Fixes gh-9282
This commit expands the support of PooledConnectionFactory so that
binding the third party object is no longer necessary. All 3rd party
properties are now deprecated in favour of our explicit support.
The main reason behind this change is that a `connection-factory` and
`properties` property were exposed. The former is used to set the
`ConnectionFactory` and makes no sense as a key. The latter is
rebuilding the underlying `ActiveMQConnectionFactory` at each call
without reusing any existing settings.
Closes gh-9837
Previously, if a user's configuration class provided a custom
Validator bean, that configuration class would be initialized very
early so that the Validator could be used to create the
auto-configured MethodValidationPostProcessor. This early
initialization could problems as it may prevent any of the
configuration class's dependencies from being post-processed.
This commit updates the injection of the Validator bean to be lazy,
thereby preventing the creation of the auto-configured
MethodValidationPostProcessor from triggering early initialization.
Closes gh-9416
Add a general purpose `Configurations` class that encapsulates the
sorting and merging rules that are usually apply. The class is
particularly useful in tests where configuration classes often need
to be specified, but an `@Import` or `ImportSelector` cannot be easily
used.
Two `Configurations` subclasses have been initially added. The
`UserConfigurations` class can be used to represent user defined
configuration and the `AutoConfigurations` class can be used to
represent a subset of auto-configurations. Auto configurations are
sorted using the same `@AutoConfiguraionBefore`/`@AutoConfiguraionAfter`
logic as the `@EnableAutoConfiguration` annotation.
Fixes gh-9795
PR #7672 Added support for arbitrary common properties.
However, Kafka emits a warning if a producer configuration contains
properties intended only for consumers, and vice versa.
The documentation showed a sample of how to write code to configure
arbitrary properties but this is inconvenient.
Add arbitrary properties to the consumer and procucer configs.
See gh-9775
This commit introduces `CodecCustomizer`, a new callback-based interface
for customizing the codecs configuration for WebFlux server and client.
Instances of those customizers are applied to the `WebClient.Builder`
and to the `WebFluxAutoConfiguration` (which deals with both WebFlux and
WebFlux.fn).
For now, only Jackson codecs are auto-configured, by getting the
`ObjectMapper` instance created by Spring Boot. Other codecs can be
configured as soon as WebFlux supports those.
Closes gh-9166
This commit adds a new customizer interface for applying
configuration changes to `WebClient.Builder` beans:
`WebClientCustomizer`.
The new WebClient auto-configuration will make available, as a
prototype scoped bean, `WebClient.Builder` instances.
Once injected, developers can use those to create `WebClient`
instances to be used in their application.
`WebClientCustomizer` beans are sorted according to their
`Order` and then applied to the builder instances.
Closes gh-9522
This commit adds ContextLoader, a test helper that configures an
ApplicationContext that is meant to simulate a particular
auto-configuration scenario.
The auto-configuration, user configuration and environment can be
customized. The loader invokes a ContextConsumer to assert the context
and automatically close the context once it is done.
Concretely, tests can create a shared field instance of that helper with
the shared configuration to increase its visibility and tune the context
further in each test.
If the context is expected to fail, `loadAndFail` allows to optionally
assert the root exception and consume it for further assertions.
This commit also migrates some tests to illustrate the practical use of
the helper
Closes gh-9634
This commit removes the only use of the `javax.annotation.Resource`
annotation from the codebase. This ensures that injection point are
only defined with Spring's annotation model.
Closes gh-9441
This commit updates Spring Session auto-configuration to ensure
compatibility with extraction of `SessionRepository` implementations into
separate Spring Session modules.
See gh-9554
This commit makes sure that each test runs with the proper datasource
auto-configuration and with an isolated embedded database. This allows
to restrict each test to only what it is supposed to do (rather than
disabling initialization to work around the fact that database is not
in a proper state because it is shared).
Closes gh-9579
This commit makes sure that if the `register-mbeans` property of the
Hikary datasource config is set, Spring Boot doesn't attempt to expose
the mbean again.
Closes gh-5114
This commit add the support for CustomConversions in
spring-data-cassandra. To customize, bean just need to be declared and
it will be auto-configured.
See gh-8534
Elastic have announced [1] that embedded Elasticsearch is no longer
supported. This commit brings us into line with that announcement by
removing the auto-configuration that would create an Elasticsearch
Node and NodeClient.
To use the Elasticsearch auto-configuration, a user must now provide
the address of one or more cluster nodes
(via the spring.elastisearch.cluster-nodes property) which will then
be used to create a TransportClient.
See gh-9374
[1] https://www.elastic.co/blog/elasticsearch-the-server
Reducing the default to 100ms is a good compromise to retain a quiet time
in for parallel execution and optimize for default, single-threaded
execution (such as test execution or regular application shutdown). The
shutdown timeout can be adjusted to fit specific application needs.
See gh-9526
Rather than checking if Jedis is on the classpath, this commit changes
the conditions of `RedisRepositoriesAutoConfiguration` to check for the
presence of a `RedisConnectionFactory` bean that is going to be
necessary to create the Redis repositories anyway.
Checking for Jedis is no longer correct since we now support Lettuce as
well.
Closes gh-9523
We now use LettuceClientConfiguration and JedisClientConfiguration to
configure connection factories. Client-specific configuration can be
customized by providing LettuceClientConfigurationBuilderCustomizer and
JedisClientConfigurationBuilderCustomizer beans.
See gh-9510, gh-8894, gh-9490
This commit reworks the property to be an enum with the list of
supported listener types rather than a boolean that flip to a
batch listener.
Closes gh-9448
Force the use of the http Neo4j driver as the bolt one attempts to
connect to the server on startup by default (and there is no way to
disable that behaviour).
See https://github.com/neo4j/neo4j-java-driver/issues/380
Closes gh-9499
Remove test-jar artifacts from Maven projects and relocate classes. The
majority of utilities now live in the `spring-boot-testsupport` module.
This update will help us to deploy artifacts using the standard Maven
deploy plugin in the future (which doesn't support the filtering of
individual artifacts).
Fixes gh-9493
CompositeContentTypeResolver was recently removed [1] and
WebFluxConfigurationSupport now creates a RequestedContentTypeResolver
bean instead. This commit updates WebFluxAutoConfigurationTests
accordingly.
[1] 01a92517bd
`QuartzAutoConfigurtion` currently blows up if there are multiple
`Executor` beans in the context.
This commit changes the configuration to retrieve `Executor` bean using
`ObjectProvider#getIfUnique` which won't fail in scenarios where there
are multiple `Executor` beans with none marked as `@Primary`.
Closes gh-9434
In an MVC web application, DelegatingWebMvcConfiguration provides the
ConversionService while also consuming WebMvcConfigurerAdapters that,
among other things, can configure HTTP message converters. Boot's
WebMvcConfigurerAdapter, WebMvcAutoConfigurationAdapter, consumes
the HttpMessageConverters bean and uses it to configure Spring MVC's
HTTP message converters. This can create a bean dependency cycle if
an HTTP message converter bean depends, directly or indirectly on
the ConversionService. An example of the cycle is:
┌─────┐
| jsonComponentConversionServiceCycle.ThingDeserializer defined in …
↑ ↓
| org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration
↑ ↓
| org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter
↑ ↓
| org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration
↑ ↓
| mappingJackson2HttpMessageConverter defined in class path resource [org/springframework/boot/autoconfigure/web/JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration.class]
↑ ↓
| jacksonObjectMapper defined in class path resource [org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$JacksonObjectMapperConfiguration.class]
└─────┘
This commit breaks the cycle by making WebMvcAutoConfigurationAdapter
consume HttpMessageConverters lazily. This allows the adapter to be
created without triggered instantiation of every HTTP message
converter bean and all their dependencies. This allows it to be
injected into DelegatingWebMvcConfiguration without triggering an
attempt to retrieve the ConversionService.
Closes gh-9409
If the auto-configured `Scheduler` instance backed by JDBC job store is
used as a dependency in an application component, the initialization of
`Scheduler` will be triggered before `QuartzDatabaseInitializer`. This
will result in failure due to schema not being prepared in time for
`Scheduler` to populate job details.
This commit ensures `QuartzDatabaseInitializer` is initialized before the
auto-configured `Scheduler` by introducing a dependency between the two.
See gh-9411
This commit removes the `client` namespace for InfluxDB as the
component that is created is `InfluxDB`, not `InfluxDBClient` or
something.
This aligns with all the other url/user/password properties Spring
Boot provides already
See gh-9066
This commit makes sure to reuse an existing or auto-configured
`JdbcTemplate` when auto-configuring a `NamedParameterJdbcTemplate`.
This ensures that whatever customizations have been applied on the
`JdbcTemplate` are properly shared.
Closes gh-4945
This commit adds support for configuring Spring Data Web
`PageableHandlerMethodArgumentResolver` and
`SortHandlerMethodArgumentResolver` using configuration properties.
See gh-9339
Since SPR-15536, WebFlux.fn is now configured with `@EnableWebFlux`,
along the annotated controllers. Both `RouterFunction` and Controller
instances can now live within the same application and they share
the same web infrastructure.
This commit removes the custom auto-configuration for `RouterFunction`
and relies on `@EnableWebFlux` for that.
Closes gh-9165
This change aligns ErrorAttributes with ResponseEntityExceptionHandler
which takes a WebRequest as a parameter of its handleException method.
WebRequest extends RequestAttributes and provides access to much more
than just the request's attributes. For example request headers and
parameters are available from WebRequest.
Closes gh-7952
Closes gh-6555