diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/asciidoc/endpoints/caches.adoc b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/asciidoc/endpoints/caches.adoc
index 6342cf77c7..7c795aca1e 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/asciidoc/endpoints/caches.adoc
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/asciidoc/endpoints/caches.adoc
@@ -7,7 +7,6 @@ The `caches` endpoint provides access to the application's caches.
[[caches-all]]
== Retrieving All Caches
-
To retrieve the application's caches, make a `GET` request to `/actuator/caches`, as
shown in the following curl-based example:
@@ -21,7 +20,6 @@ include::{snippets}caches/all/http-response.adoc[]
[[caches-all-response-structure]]
=== Response Structure
-
The response contains details of the application's caches. The following table describes
the structure of the response:
@@ -32,7 +30,6 @@ include::{snippets}caches/all/response-fields.adoc[]
[[caches-named]]
== Retrieving Caches by Name
-
To retrieve a cache by name, make a `GET` request to `/actuator/caches/{name}`,
as shown in the following curl-based example:
@@ -47,7 +44,6 @@ include::{snippets}caches/named/http-response.adoc[]
[[caches-named-request-structure]]
=== Request Structure
-
If the requested name is specific enough to identify a single cache, no extra parameter is
required. Otherwise, the `cacheManager` must be specified. The following table shows the
supported query parameters:
@@ -59,7 +55,6 @@ include::{snippets}caches/named/request-parameters.adoc[]
[[caches-named-response-structure]]
=== Response Structure
-
The response contains details of the requested cache. The following table describes the
structure of the response:
@@ -70,7 +65,6 @@ include::{snippets}caches/named/response-fields.adoc[]
[[caches-evict-all]]
== Evict All Caches
-
To clear all available caches, make a `DELETE` request to `/actuator/caches` as shown in
the following curl-based example:
@@ -80,7 +74,6 @@ include::{snippets}caches/evict-all/curl-request.adoc[]
[[caches-evict-named]]
== Evict a Cache by Name
-
To evict a particular cache, make a `DELETE` request to `/actuator/caches/{name}` as shown
in the following curl-based example:
@@ -93,7 +86,6 @@ specify which `Cache` should be cleared.
[[caches-evict-named-request-structure]]
=== Request Structure
-
If the requested name is specific enough to identify a single cache, no extra parameter is
required. Otherwise, the `cacheManager` must be specified. The following table shows the
supported query parameters:
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/asciidoc/endpoints/integrationgraph.adoc b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/asciidoc/endpoints/integrationgraph.adoc
index 8d0e3a19cc..469cfa6f78 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/asciidoc/endpoints/integrationgraph.adoc
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/asciidoc/endpoints/integrationgraph.adoc
@@ -8,7 +8,6 @@ components.
[[integrationgraph-retrieving]]
== Retrieving the Spring Integration graph
-
To retrieve the information about the application, make a `GET` request to
`/actuator/integrationgraph`, as shown in the following curl-based example:
@@ -22,7 +21,6 @@ include::{snippets}integrationgraph/graph/http-response.adoc[]
[[integrationgraph-retrieving-response-structure]]
=== Response Structure
-
The response contains all Spring Integration components used within the application, as
well as the links between them. More information about the structure can be found in the
https://docs.spring.io/spring-integration/reference/html/system-management-chapter.html#integration-graph[reference
@@ -32,7 +30,6 @@ documentation].
[[integrationgraph-rebuilding]]
== Rebuilding the Spring Integration graph
-
To rebuild the exposed graph, make a `POST` request to `/actuator/integrationgraph`, as
shown in the following curl-based example:
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebClientMetricsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebClientMetricsAutoConfiguration.java
index a0d0de491c..c156497214 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebClientMetricsAutoConfiguration.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebClientMetricsAutoConfiguration.java
@@ -39,7 +39,6 @@ import org.springframework.web.reactive.function.client.WebClient;
/**
* {@link EnableAutoConfiguration Auto-configuration} for instrumentation of
* {@link org.springframework.web.reactive.function.client.WebClient}.
- *
*
* This is reusing the {@link io.micrometer.core.instrument.config.MeterFilter} defined in
* {@link RestTemplateMetricsAutoConfiguration} for limiting the cardinality of "uri"
diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java
index 7f51bd4229..8e9c20a577 100644
--- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java
+++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java
@@ -59,11 +59,13 @@ public class CachesEndpoint {
@ReadOperation
public CachesReport caches() {
Map> descriptors = new LinkedHashMap<>();
- getCacheEntries((name) -> true, (cacheManager) -> true).forEach((entry) -> {
- Map cmDescriptors = descriptors.computeIfAbsent(
- entry.getCacheManager(), (key) -> new LinkedHashMap<>());
- String cache = entry.getName();
- cmDescriptors.put(cache, new CacheDescriptor(entry.getTarget()));
+ getCacheEntries(matchAll(), matchAll()).forEach((entry) -> {
+ String cacheName = entry.getName();
+ String cacheManager = entry.getCacheManager();
+ Map cacheManagerDescriptors = descriptors
+ .computeIfAbsent(cacheManager, (key) -> new LinkedHashMap<>());
+ cacheManagerDescriptors.put(cacheName,
+ new CacheDescriptor(entry.getTarget()));
});
return new CachesReport(descriptors);
}
@@ -79,7 +81,7 @@ public class CachesEndpoint {
@ReadOperation
public CacheEntry cache(@Selector String cache, @Nullable String cacheManager) {
return extractUniqueCacheEntry(cache,
- getCacheEntries((name) -> name.equals(cache), safeEqual(cacheManager)));
+ getCacheEntries((name) -> name.equals(cache), isNameMatch(cacheManager)));
}
/**
@@ -87,14 +89,13 @@ public class CachesEndpoint {
*/
@DeleteOperation
public void clearCaches() {
- getCacheEntries((name) -> true, (cacheManagerName) -> true)
- .forEach(this::clearCache);
+ getCacheEntries(matchAll(), matchAll()).forEach(this::clearCache);
}
/**
* Clear the specific {@link Cache}.
* @param cache then name of the cache
- * @param cacheManager the name of the cacheManager (can be {@code null}
+ * @param cacheManager the name of the cacheManager (can be {@code null} to match all)
* @return {@code true} if the cache was cleared or {@code false} if no such cache
* exists
* @throws NonUniqueCacheException if more than one cache with that name exist and no
@@ -102,7 +103,7 @@ public class CachesEndpoint {
@DeleteOperation
public boolean clearCache(@Selector String cache, @Nullable String cacheManager) {
CacheEntry entry = extractUniqueCacheEntry(cache,
- getCacheEntries((name) -> name.equals(cache), safeEqual(cacheManager)));
+ getCacheEntries((name) -> name.equals(cache), isNameMatch(cacheManager)));
return (entry != null && clearCache(entry));
}
@@ -131,12 +132,13 @@ public class CachesEndpoint {
entries.stream().map(CacheEntry::getCacheManager).distinct()
.collect(Collectors.toList()));
}
- return (entries.isEmpty() ? null : entries.get(0));
+ return (!entries.isEmpty() ? entries.get(0) : null);
}
private boolean clearCache(CacheEntry entry) {
String cacheName = entry.getName();
- Cache cache = this.cacheManagers.get(entry.getCacheManager()).getCache(cacheName);
+ String cacheManager = entry.getCacheManager();
+ Cache cache = this.cacheManagers.get(cacheManager).getCache(cacheName);
if (cache != null) {
cache.clear();
return true;
@@ -144,9 +146,12 @@ public class CachesEndpoint {
return false;
}
- private Predicate safeEqual(String name) {
- return (name != null ? ((requested) -> requested.equals(name))
- : ((requested) -> true));
+ private Predicate isNameMatch(String name) {
+ return (name != null ? ((requested) -> requested.equals(name)) : matchAll());
+ }
+
+ private Predicate matchAll() {
+ return (name) -> true;
}
/**
diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpoint.java
index f2e034e873..a4be984bd9 100644
--- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpoint.java
+++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpoint.java
@@ -34,8 +34,9 @@ public class IntegrationGraphEndpoint {
private final IntegrationGraphServer graphServer;
/**
- * Create a new {@code IntegrationGraphEndpoint} that exposes a graph containing all
- * the Spring Integration components in the given {@link IntegrationGraphServer}.
+ * Create a new {@code IntegrationGraphEndpoint} instance that exposes a graph
+ * containing all the Spring Integration components in the given
+ * {@link IntegrationGraphServer}.
* @param graphServer the integration graph server
*/
public IntegrationGraphEndpoint(IntegrationGraphServer graphServer) {
diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointTests.java
index d4f5808ae5..59c9339df2 100644
--- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointTests.java
+++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointTests.java
@@ -26,9 +26,9 @@ import org.springframework.integration.support.management.graph.Graph;
import org.springframework.integration.support.management.graph.IntegrationGraphServer;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.BDDMockito.mock;
-import static org.mockito.BDDMockito.verify;
-import static org.mockito.BDDMockito.when;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
/**
* Tests for {@link IntegrationGraphEndpoint}.
@@ -51,8 +51,7 @@ public class IntegrationGraphEndpointTests {
@Test
public void readOperationShouldReturnGraph() {
Graph mockedGraph = mock(Graph.class);
- when(this.integrationGraphServer.getGraph()).thenReturn(mockedGraph);
-
+ given(this.integrationGraphServer.getGraph()).willReturn(mockedGraph);
Graph graph = this.integrationGraphEndpoint.graph();
verify(this.integrationGraphServer).getGraph();
assertThat(graph).isEqualTo(mockedGraph);