Previously, RestTemplateBuilder and WebClient.Builder beans were used
to create the HTTP client for sending out spans. Those same beans are
also instrumented for observability which results in a cycle.
This commit breaks the cycle by not using the application-web
builders to create the RestTemplate and WebClient's used by the Zipkin
senders. Instead, builders are created inline, with new callbacks
being introduced to allow the user to customize these Zipkin-specific
builders.
See gh-32528
Previously, a Webclient-based sender was only for reactive web
applications, falling back to a RestTemplate-based sender in all
other cases.
With this commit we now prefer to use WebClient if it is available,
irrespective of the web application type. The assumption is that
if the user has WebClient on the classpath, it's either a reactive
web application, or it's a servlet web application or non-web
application but WebClient is preferred.
See gh-32529
Prior to this commit, Spring Boot would auto-configure a customizer that
instruments `RestTemplate` through a `RestTemplateBuilder`. This would
install a request interceptor that instrumented client exchanges for
producing metrics.
As of spring-projects/spring-framework#28341, the instrumentation is
done at the `RestTemplate` level directly using the `Observation` API.
The `Tag` (now `KeyValue`) extraction, observation name and
instrumentation behavior now lives in the Spring Framework project.
This commit updates the auto-configuration to switch from Boot-specific
Metrics instrumentation to a generic Observation instrumentation.
As a migration path, some configuration properties are deprecated in
favor of the new `management.observations.*` namespace.
Closes gh-32484
This commit updates Servlet based Spring Security auto-configuration
to use AuthorizationFilter, which is intended to supersede
FilterSecurityInterceptor.
See gh-31255
This was regressed in 6175c4210d so that
each class on the classpath was passed in as a "root". This commit
corrects this so that only the roots are passed to the AOT test
processor.
See gh-32424
With this commit, loading `@AutoConfiguration`,
`@ImportAutoConfiguration`, and `@ManagementContextConfiguration`
classes is supported with `.imports` files only. Support for loading
these classes with `spring.factories` is removed.
Closes gh-29699
This commit mentions the `"classpath*:graphql/**` schema location in
case the application needs to find schemas across multiple classpath
roots, for example across multiple modules.
Closes gh-31772
With Spring Session moving to RedisSessionRepository as the preferred
session repository, Spring Boot auto-configuration should make it
possible to easily switch back to the previous default
(RedisIndexedSessionRepository).
This commit introduces spring.session.redis.repository configuration
property that allows selecting the desired Redis-backed session
repository implementation.
See gh-32205
Batch is now auto-configured to use the context's
PlatformTransactionManager and DataSource or `@BatchDataSource`.
When this does not meet the user's needs, they can use
`@EnableBatchProcessing` or sub-class `DefaultBatchConfiguration` to
take complete control with the auto-configuration backing off.
Closes gh-32330
This commit disables ContextCustomizer implementations that tune a
test configuration context at runtime. Previously, these ran again and
required additional hints to work properly.
Rather than contributing those hints, the customizer is skipped as its
impact is irrelevant in an AOT-optimized context: the context is fully
prepared and the updates on the MergedContextConfiguration are not taken
into account.
Closes gh-32422
When the Spring Boot Gradle plugin builds a fat jar and the Native
Build Tools Gradle plugin is applied to the build, any configuration
files from the GraalVM reachability metadata repository that match
project dependencies are copied to a `META-INF/native-image`
directory in the fat jar.
Closes gh-32408
Previously, when using Tomcat, its web app class loader was the thread
context class loader when H2ConsoleAutoConfiguration triggered
initialization of Hikari's pool. This was the case because it's done
in the bean method of a ServletRegistrationBean. Such Servlet-related
beans are intentionally created with Tomcat's web app classloader as
the TCCL. This arrangement results in the pool's threads using
Tomcat's web app class loader as their TCCL which is not desirable.
One consequence of this was that Tomcat could log a warning at
shutdown about the thread being left running when it will, in fact,
be stopped as part of the context being closed.
This commit updates H2ConsoleAutoConfiguration to set the TCCL to its
own ClassLoader while the DataSource information is being logged.
Closes gh-32382
Previously, the AOT-generated classes were added directly to the
compile classpath of the AOT compilation task. This didn't work
perfectly in IntelliJ IDEA, leaving the generated classes in the
runtime scope and causing compilation problems where the
AOT-generated source tried to reference those classes.
This commit updates the plugin to add the AOT-generated classes as
a dependency to the AOT source set's implementation configuration.
This makes the classes available during compilation by the source
set's Java compilation task while also makeing IntelliJ IDEA aware
of their presence on the compile classpath.
Closes gh-32395
Update `SpringBootContextLoader` so that it now implements the
`AotContextLoader` interface. The `ContextLoaderHook` will abandon
at `contextLoaded` if the test class is being AOT processed.
This commit also introduces a new `AotApplicationContextInitializer`
which allows us to plug-in an alternative AOT application context
listener when the `SpringApplication` is running in test mode.
Closes gh-31965
Update `spring-boot-start-parent` with a new `nativeTest` profile. When
active, this profile will trigger AOT processing of test code and call
the native build tools 'test' goal.
Closes gh-32383
Add a new `useMainMethod` attribute to `SpringBootTest` which can be
used to determine how the test should run. The three available options
are:
- `ALWAYS`
- `NEVER`
- `WHEN_AVAILABLE`
The default is `WHEN_AVAILABLE` which will attempt to launch the test
using the `main` method if there is one.
The `SpringBootContextLoader` has been updated to use the new
`SpringApplicationHook` interface when the main method is being used.
Closes gh-22405
Create a new public SpringApplication Hook API based on the existing
`SpringApplicationRunListener` interface.
The previous package-private `SpringApplicationHooks` class has been
replaced with a public `SpringApplicationHook` interface which acts as
a factory that can create additional `SpringApplicationRunListener`
instances to hook in.
The boolean result from the previous `preRefresh` method has been
replaced with an `AbandonedRunException` which can be thrown from
the `SpringApplicationRunListener`.
Closes gh-32301
Update `EventPublishingRunListener` so that event listeners may add
additional listeners to the `SpringApplication` during early events.
Prior to this commit, the listeners were collected only once which
meant that if a listener for an `ApplicationStartingEvent` called
`application.addListener(...)`, it would be ignored.
Closes gh-32300