This commit makes sure to respect the MBeanServer#invoke contract by
wrapping any user-defined exception in an MBeanException. Also, any
exception not from the JDK is translated, as it may lead to unexpected
issue on the client if that class isn't present. This is consistent
with our operation result mapping strategy.
Closes gh-10448
As pointed out by Rossen in gh-11514 comments, a handler might commit
the response and then send an error signal in the pipeline. In this
case, adding a callback to `beforeCommit` is useless because it won't be
triggered. In those cases, we need to collect metrics right away.
Spring Boot now deploys both annotation-based and functional endpoints
under the same `HttpHandler`; this means the currently auto-configured
`MetricsWebFilter` is instrumenting all endpoints to produce metrics.
There is no need for a WebFlux functional specific support.
This commit removes mentions of `RouterFunctionMetrics` in the docs and
deprecates that class.
Closes gh-12833
Prior to this commit, the metrics `WebFilter` would handle exceptions
flowing through the pipeline and extract tag information right away.
Since error handling turns the exception information into error HTTP
responses later in the chain, the information extracted from the
response earlier is invalid.
In this case, the "status" information could be "200" whereas error
handlers would later set that status to "500".
This commit delays the tags extraction later in the process, right
before the response is comitted. The happy path is not changed, as
handlers signal that the response is fully taken care of at that point.
Fixes gh-11514
Previously to this commit, if a `@ControllerEndpoint`,
`@RestControllerEndpoint` or `@ServletEndpoint` annotated bean was
proxied, the endpoint wasn't properly detected.
This commit makes sure that annotation retrieval works on the user class
while preserving the get (vs. find) retrieval semantic
Closes gh-12441
This commit ensures that `WebFluxTags` not only relies on
`BEST_MATCHING_PATTERN_ATTRIBUTE` or request URI to provide the "uri"
tag information.
To avoid cardinality explosion, HTTP not found and redirects are
assigned fixed uri tags.
Closes gh-12685
Prior to this commit, `WebMvcTags' would always mark as "NOT_FOUND" or
"REDIRECTION" *any* exchange with responses of 404 and 3xx status, even
if those responses are actually returned by Controller handlers.
This commit checks inverts those checks and first considers if the
"BEST_MATCHING_PATTERN_ATTRIBUTE" request attribute is present and uses
it - then falls back to "NOT_FOUND" and "REDIRECTION" to avoid
cardinality explosion.
Fixes gh-12577
Create a new `ApplicationConversionService` similar in design to the
DefaultFormattingConversionService from Spring Framework. The new
conversion service provides a central place for custom conversion logic
supported by Spring Boot.
Also replace the `BindingConversionService` with an internal
`BindConverter` class that now invokes the `SimpleTypeConverter`
directly. Binding for `@ConfigurationProperties` has been updated so
that any custom property editors registered with the BeanFactory can
be used.
Fixes gh-12095
Move leading slash logic from `MetricsClientHttpRequestInterceptor` to
`RestTemplateExchangeTags` so that URI based calls are also managed.
Closes gh-12126
Previously, if a controll endpoint included a mapping with no path,
it would be mapped to the root of the application rather than the
root of the endpoint's path.
This commit updates the handler mappings for both reactive and Servlet
web applications to treat a mapping with no paths as being a mapping
with a single empty path. This ensures that a path with the endpoint's
path prepended is used for the mapping.
Closes gh-12104
Remove custom `SpringIntegrationMetrics` and instead provide
auto-configuration to the direct Micrometer support added in Spring
Integration 5.0.2.
Closes gh-11985
Previously, links were only provide to web endpoints. This commit
expands link resolution to also provide links for servlet endpoints,
controller endpoints, and rest controller endpoints.
Closes gh-11902
Update `GitProperties` so that the `commit.id` entry is also copied to
`commit.id.full`.
Prior to this commit, when returning full details, the value of
`commit.id` would be replaced with a `Map` containing only `abbriv` as
a key. By copying the value to a sub-key we ensure that it remains
available both in the FULL and SIMPLE modes.
Fixes gh-11892
Update `AbstractHealthIndicator` so that the warning message can be
customized. Also updated our existing indicators with better messages.
Fixes gh-11880
Move the "testdb" naming logic to `DataSourceProperties` and expose
the `deduceDatabaseName` method so they can be used in
auto-configuration.
See gh-11719
Previously, Hikari's pool name was auto-configured with the value of
`spring.datasource.name` that defaults to `testdb`, which brings some
confusion.
This commit removes the default `testdb` value on
`spring.datasource.name` as it is a sane default only for an embedded
datasource. It is applied whenever applicable instead.
Closes gh-11719
This commit adds InvalidEndpointRequestException as a technology
agnostic way to signal that an endpoint request is invalid. When such
exception is thrown, the web layer translates that to a 400.
Rather than overriding the reason, this commit makes sure to reuse the
error infrastructure.
Closes gh-10618
This commit makes sure that `CharacterEncodingFilter` is ordered with
the `Ordered.HIGHEST_PRECEDENCE` and that other filters, potentially
reading the request body, are ordered after.
In this particular case, both `WebMvcMetricsFilter` and
`ErrorPageFilter` are now ordered at `Ordered.HIGHEST_PRECEDENCE + 1` to
avoid cases where the request body is read before the encoding
configuration is taken into account.
Closes gh-11607
Add `@ControllerEndpoint` and `@RestControllerEndpoint` annotations that
can be used to develop a Spring-only request mapped endpoint. Both
Spring MVC and Spring WebFlux are supported.
This feature is primarily for use when deeper Spring integration is
required or when existing Spring Boot 1.5 projects want to migrate to
Spring Boot 2.0 without re-writing existing endpoints. It comes at the
expense of portability, since such endpoints will be missing from
Jersey.
Fixes gh-10257
Create a `PathMappedEndpoint` interface that allows any `ExposedEndpoint`
to provide root path details. The `EndpointPathResolver` interface has
been renamed to `PathMapper` and is now only used during endpoint
discovery.
`EndpointPathProvider` has been replaced with `PathMappedEndpoints`
which simply finds relevant path mapped endpoints.
Fixes gh-10985
Refactor several areas of the actuator endpoint code in order to make
future extensions easier. The primary goal is to introduce the concept
of an `ExposableEndpoint` that has technology specific subclasses and
can carry additional data for filters to use. Many other changes have
been made along the way including:
* A new EndpointSupplier interface that allows cleaner separation of
supplying vs discovering endpoints. This allows cleaner class names
and allows for better auto-configuration since a user can choose to
provide their own supplier entirely.
* A `DiscoveredEndpoint` interface that allows the `EndpointFilter`
to be greatly simplified. A filter now doesn't need to know about
discovery concerns unless absolutely necessary.
* Improved naming and package structure. Many technology specific
concerns are now grouped in a better way. Related concerns are
co-located and concepts from one area no longer leakage into another.
* Simplified `HandlerMapping` implementations. Many common concerns have
been pulled up helping to create simpler subclasses.
* Simplified JMX adapters. Many of the intermediary `Info` classes have
been removed. The `DiscoveredJmxOperation` is now responsible for
mapping methods to operations.
* A specific @`HealthEndpointCloudFoundryExtension` for Cloud Foundry.
The extension logic used to create a "full" health endpoint extension
has been made explicit.
Fixes gh-11428
Fixes gh-11581
Previously, the server was created with out an explicitly configured
address. This lead to it using any local address which will prefer
IPv6 (::0) if it's available. By contrast, the client was created
with a base URL that specified localhost as the host. This meant the
the client would prefer to connect to IPv4. Normally this wouldn't
cause a problem as nothing would be listening on the port in the IPv4
stack so the client would then connect to the server being tested
using the IPv6 stack. However, if another process was listening to the
port in the IPv4 stack, the client would connect to the wrong server.
This could lead to an unexpected 404 response (if the wrong server
was an HTTP server) or a hang if it was not.
There's a chance, although I think it's unlikely, that the problem
described above is the cause of gh-10569. I think it's unlikely as
the hang tracked by gh-10569 only occurs when running the WebFlux
endpoint integration tests using Reactor Netty. If it was the problem
described above, there's no reason that I can think of why we
wouldn't have also seen it with the Web MVC endpoint integration
tests.
Improve the structure of the response and include mappings from
WebFlux and Servlet and Filter registrations in addition to the
mappings from Spring MVC.
Closes gh-9979
Previously, a number of Actuator endpoints ignored a context hierarchy
or assumed that it would always be linear. This commit reworks the
affected endpoints so that the no longer assume a linear hierarchy.
A side-effect of a non-linear hierarchy is that there may be multiple
different beans with the same name (in a linear hierarchy, a bean
with the same name as one in an ancestor context, replaces that bean).
The affected endpoints have also been updated so that, when bean names
are used as keys, those keys are grouped by application context. This
prevents a bean in one context from accidentially overwriting a bean
in another context.
Closes gh-11019
Change `CacheMeterBinderProvider` to include a cache type
generic which helps to simplify implementations. Also move
and extract a few classes.
See gh-11221
This commit improve the couchbase health indicator to list the available
nodes. Doing so improves the reliability of the indicator as accessing
the bucket forces a remote call and better detect the cases where the
broker is down.
Closes gh-7369