Split the JUnit 5 `OutputCapture` class into separate `OutputExtension`
and `CapturedOutput` classes. The JUnit 5 callback methods are now
contained only in the `OutputExtension` class so no longer pollute the
public API that users will interact with.
The `CapturedOutput` class has also been updated to capture System.err
and System.out separately to allow distinct assertions if required.
Closes gh-17029
Refactor `Autotime` from a properties object to an interface and
change the existing metric recording implementations. The `AutoTimer`
interface is a general purpose callback that can be applied to a
`Timer.Builder` to configure it. Autotime properties are now located
in `spring-boot-actuator-autoconfigure` and have become an
implementation of the interface.
Closes gh-17026
This commit merges the conditions for determining if an endpoint is
available in a single condition, deprecating
`ConditionalOnEnabledEndpoint` in the process.
Closes gh-16169
Prior to this commit, the audit auto-configuration provided
an `InMemoryAuditEventRepository` bean. This commit changes the auto-config
so that an `AuditEventRepository` is not provided and instead the auto-config
is conditional on the presence of a `AuditEventRepository` bean. This is done
to encourage the use of a custom implementation of `AuditEventRepository`
since the in-memory one is quite limited and not suitable for production.
A flag is available if the auto-configuration needs to be turned off even
in the presence of a bean.
Closes gh-16110
Prior to this commit, the http trace auto-configuration provided
an `InMemoryHttpTraceRepository` bean. This commit changes the auto-config
so that an `HttpTraceRepository` is not provided and instead the auto-config
is conditional on the presence of a `HttpTraceRepository` bean. This is done
to encourage the use of a custom implementation of `HttpTraceRepository`
since the in-memory one is quite limited and not suitable for production.
A flag is available if the auto-configuration needs to be turned off even
in the presence of a bean.
Closes gh-15039
When `management.metrics.web.server.auto-time-requests` is enabled
(default=true), Spring Boot collects metrics on controller methods even
when they are not annotated with `@Timed`.
When this happens, created metrics are based on the default
`@Timed` configuration and there is no way to customize the
configuration of those auto-timed controller metrics.
This commit adds default configurations to auto-timed requests on both
client and server sides.
See gh-15988
This commit also adds tests to ensure that the child
management context works when lazy initialization is
enabled. Also, it adds a BeanFactoryPostProcessor to
the child context so that the server is created and
listening for requests but other beans in the child
context are not created until requested.
See gh-16184
This commit migrates `AnnotationConfigReactiveWebApplicationContext`
parent to the `GenericApplicationContext` abstraction. Any use of
`AnnotationConfigWebApplicationContext` is also removed as it also
inherits from the `AbstractRefreshableApplicationContext` outdated
hierarchy.
A new `AnnotationConfigServletWebApplicationContext` context is
introduced instead, extending from `GenericApplicationContext` and
providing the counter part of the reactive context for the Servlet-based
web app tests.
See gh-16096
This commit updates CORS handling according to Framework changes
introduced via [1]. It also fixes tests according to the new behavior.
See gh-16410
[1] d27b5d0ab6.
This commit replaces the default Asciidoctor styling with
Spring specific styling.
First, we need to unzip the contents of the Spring Asciidoctor
documentation resources provided by the
`io.spring.docsresources:spring-docs-resources` distribution zip. This
is done in a `/target/refdocs` folder. We then copy all files from
`src/main/asciidoc` to the same location, and then launch the generation
process.
See gh-16326
Update the `CustomEndpointConfiguration` class in
`ScheduledTasksEndpointAutoConfigurationTests` to be package private
so that it can be enhanced by cglib.
Prior to merge commit 361437f4 the class was a lite configuration so
it didn't matter that it was a private class.
Previously, environment binding always happened in a post processor once
the bean has been created. Constructor binding requires to perform the
binding at creating time so this commit performs binding at creation
time if possible.
When this happens, a special `ConfigurationPropertiesBeanDefinition` is
created with a supplier that invokes the binder. To avoid a case where
a bean is processed twice, the post-processor now ignores any bean that
has already been bound to the environment.
Closes gh-8762
Co-authored-by: Madhura Bhave <mbhave@pivotal.io>
This commit adds the newly introduced `@ConditionalOnExposedEndpoint`
conditional annotation to all auto-configured `Endpoint` in Actuator.
With that change, `EndPoint` instances and related infrastructure will
only be created when they are meant to be exposed and used. This will
save CPU and memory resources when Actuator is present.
Closes gh-16093
Prior to this commit, Actuator `Endpoint` instantiations would be
guarded by `@ConditionalOnEnabledEnpoint` condition annotations. This
feature saves resources as disabled endpoints aren't unnecessarily
instantiated.
By default, only `"health"` and `"info"` endpoints are exposed over the
web and all endpoints are exposed over JMX.
As of gh-16090, JMX is now disabled by default. This is an opportunity
to avoid instantiating endpoints if they won't be exposed at all, which
is more likely due to the exposure defaults.
This commit adds a new `@ConditionalOnExposedEndpoint` conditional
annotation that checks the `Environment` for configuration properties
under `"management.endpoints.web.exposure.*"` and
`"management.endpoints.jmx.exposure.*"`. In the case of JMX, an
additional check is perfomed, checking that JMX is enabled first.
The rules implemented in the condition itself are following the ones
described in `ExposeExcludePropertyEndpointFilter`.
See gh-16093
This commit switches the default value for the `spring.jmx.enabled`
configuration property.
JMX is now disabled by default and can be enabled with
`spring.jmx.enabled=true`.
Closes gh-16090
This commit splits the management context configuration for jersey
into two separate configurations depending on if the type is SAME or
CHILD. The configuration for the SAME context should only kick in if
there is no existing ResourceConfig bean.
Fixes gh-15891
This commit also ensures that Jersey-based actuator endpoints are
available before the user has configured a `ResourceConfig` bean
Fixes gh-15625
Fixes gh-15877
Previously, MeterRegistryPostProcessor would trigger the creation of all
meter binders and meter registry customizers before applying the
customizers and calling the binders. In some situations with complex
dependency graphs where the creation of a binder and the injection of
its dependencies inadvertently triggered some meter binding, this
could result in meters being bound before the registry had been
customized.
This commit reworks MeterRegistryPostProcessor and MeterRegistryConfigurer
to defer the retrieval of registry customizers and meter binders until
just before they are needed. As a result, customizers are now retrieved
and applied before the binders are retrieved.
Closes gh-15483
This commit adds `ElasticsearchRestHealthIndicator`, a new
`HealthIndicator` for Elasticsearch, using the Elasticsearch "low level
rest client" provided by the
`"org.elasticsearch.client:elasticsearch-rest-client"` dependency.
Note that Spring Boot will auto-configure both low and high level REST
clients, but since the high level one is using the former, a single
health indicator will cover both cases.
See gh-15211
When server and management are at different ports, and when server
requires TLS client authentication, then there is no simple method to
disable TLS client authentication for management port.
This commit adds an additional "none" option to ssl.client-auth.
Example:
server.port=8080
server.ssl.enabled=true
server.ssl.client-auth=need
management.server.port=8081
management.server.ssl.enabled=true
management.server.ssl.client-auth=none
See gh-14985
Complete the restructuring of the security auto-configuration
packages by removing the direct import of web configuration from
the main security auto-configuration.
Closes gh-14412
Update `WebEndpointDiscoverer` and related classes to that multiple
`PathMapper` beans can be registered. Mappers are now tried in order
until one returns a non-null value.
Closes gh-14841
Previously, Couchbase's health was determined by retrieving the bucket info
from the cluster info. This retrieval could take over one minute in some
cases even when Couchbase is health. This latency is too large for a health
check.
The Couchbase team have recommended the of a Cluster#diagnostics instead.
This provides a much lower latency view of the cluster's health. This
commit updates CouchbaseHealthIndicator to use Cluster#diagnostics while
retaining support, in a deprecated form, for the old info-based mechanism
should anyone want to opt back into that in 2.0.x.
Closes gh-14685
Update `MappingWebEndpointPathMapper` to use the lowercase version of
the endpoint ID when no explicit path mapping has been set. An endpoint
with the ID 'myEndpoint' will now be mapped to the path 'myendpoint'.
See gh-14773
Update `ExposeExcludePropertyEndpointFilter` so that mixed case
endpoint IDs are supported. Prior to this commit it was not easy for
an endpoint to be missed by the filter due to the formatting of the
property value.
See gh-14773
Update `OnEnabledEndpointCondition` so that mixed case endpoint IDs
are supported. Prior to this commit an
`InvalidConfigurationPropertyNameException` would be thrown when trying
to enabled or disable an endpoint with a camel case ID.
See gh-14773
Update the endpoint time-to-live binding logic so that mixed case
endpoint IDs are supported. Prior to this commit an
`InvalidConfigurationPropertyNameException` would be thrown when using
a camel case endpoint ID.
See gh-14773
Add an `EndpointID` class to enforce the naming rules that we support
for actuator endpoints. We now ensure that all endpoint names contain
only letters and numbers and must begin with a lower-case letter.
Existing public classes and interfaces have been changes so that String
based `endpointId` methods are deprecated and strongly typed versions
are preferred instead. A few public classes that we're not expecting
to be used directly have been changed without deprecated methods being
introduced.
See gh-14773