From aa817ea36c2807130e8c376f62bf95fe92a7ef3a Mon Sep 17 00:00:00 2001 From: spencergibb Date: Wed, 16 Sep 2020 17:23:52 -0400 Subject: [PATCH] Removes invalid characters from actuator endpoint ids. Fixes gh-237 --- docs/src/main/asciidoc/spring-cloud-bus.adoc | 20 +++++++++---------- .../bus/endpoint/EnvironmentBusEndpoint.java | 2 +- .../bus/endpoint/RefreshBusEndpoint.java | 2 +- .../bus/RefreshListenerIntegrationTests.java | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/src/main/asciidoc/spring-cloud-bus.adoc b/docs/src/main/asciidoc/spring-cloud-bus.adoc index 4bc3512..cb70dca 100644 --- a/docs/src/main/asciidoc/spring-cloud-bus.adoc +++ b/docs/src/main/asciidoc/spring-cloud-bus.adoc @@ -11,36 +11,36 @@ include::quickstart.adoc[] == Bus Endpoints -Spring Cloud Bus provides two endpoints, `/actuator/bus-refresh` and `/actuator/bus-env` +Spring Cloud Bus provides two endpoints, `/actuator/busrefresh` and `/actuator/busenv` that correspond to individual actuator endpoints in Spring Cloud Commons, `/actuator/refresh` and `/actuator/env` respectively. === Bus Refresh Endpoint -The `/actuator/bus-refresh` endpoint clears the `RefreshScope` cache and rebinds +The `/actuator/busrefresh` endpoint clears the `RefreshScope` cache and rebinds `@ConfigurationProperties`. See the <> documentation for more information. -To expose the `/actuator/bus-refresh` endpoint, you need to add following configuration to your +To expose the `/actuator/busrefresh` endpoint, you need to add following configuration to your application: [source,properties] ---- -management.endpoints.web.exposure.include=bus-refresh +management.endpoints.web.exposure.include=busrefresh ---- === Bus Env Endpoint -The `/actuator/bus-env` endpoint updates each instances environment with the specified +The `/actuator/busenv` endpoint updates each instances environment with the specified key/value pair across multiple instances. -To expose the `/actuator/bus-env` endpoint, you need to add following configuration to your +To expose the `/actuator/busenv` endpoint, you need to add following configuration to your application: [source,properties] ---- -management.endpoints.web.exposure.include=bus-env +management.endpoints.web.exposure.include=busenv ---- -The `/actuator/bus-env` endpoint accepts `POST` requests with the following shape: +The `/actuator/busenv` endpoint accepts `POST` requests with the following shape: [source,json] ---- @@ -65,7 +65,7 @@ constructed in the form of `app:index:id`, where: * `id` is the `vcap.application.instance_id`, if it exists, or a random value. The HTTP endpoints accept a "`destination`" path parameter, such as -`/bus-refresh/customers:9000`, where `destination` is a service ID. If the ID +`/busrefresh/customers:9000`, where `destination` is a service ID. If the ID is owned by an instance on the bus, it processes the message, and all other instances ignore it. @@ -73,7 +73,7 @@ ignore it. The "`destination`" parameter is used in a Spring `PathMatcher` (with the path separator as a colon -- `:`) to determine if an instance processes the message. Using the example -from earlier, `/bus-env/customers:**` targets all instances of the +from earlier, `/busenv/customers:**` targets all instances of the "`customers`" service regardless of the rest of the service ID. == Service ID Must Be Unique diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/EnvironmentBusEndpoint.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/EnvironmentBusEndpoint.java index b5db2ca..1c89242 100644 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/EnvironmentBusEndpoint.java +++ b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/EnvironmentBusEndpoint.java @@ -28,7 +28,7 @@ import org.springframework.context.ApplicationEventPublisher; /** * @author Spencer Gibb */ -@Endpoint(id = "bus-env") // TODO: document +@Endpoint(id = "busenv") // TODO: document public class EnvironmentBusEndpoint extends AbstractBusEndpoint { public EnvironmentBusEndpoint(ApplicationEventPublisher context, String id) { diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/RefreshBusEndpoint.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/RefreshBusEndpoint.java index 0024411..7d10064 100644 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/RefreshBusEndpoint.java +++ b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/RefreshBusEndpoint.java @@ -25,7 +25,7 @@ import org.springframework.context.ApplicationEventPublisher; /** * @author Spencer Gibb */ -@Endpoint(id = "bus-refresh") // TODO: document new id +@Endpoint(id = "busrefresh") // TODO: document new id public class RefreshBusEndpoint extends AbstractBusEndpoint { public RefreshBusEndpoint(ApplicationEventPublisher context, String id) { diff --git a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/RefreshListenerIntegrationTests.java b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/RefreshListenerIntegrationTests.java index 320e226..e0a0b2e 100644 --- a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/RefreshListenerIntegrationTests.java +++ b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/RefreshListenerIntegrationTests.java @@ -56,9 +56,9 @@ public class RefreshListenerIntegrationTests { @Test public void testEndpoint() { System.out.println(rest.getForObject("/actuator", String.class)); - assertThat(rest.postForEntity("/actuator/bus-refresh/demoapp", new HashMap<>(), String.class).getStatusCode()) + assertThat(rest.postForEntity("/actuator/busrefresh/demoapp", new HashMap<>(), String.class).getStatusCode()) .isEqualTo(HttpStatus.NO_CONTENT); - assertThat(rest.postForEntity("/actuator/bus-refresh/foobar", new HashMap<>(), String.class).getStatusCode()) + assertThat(rest.postForEntity("/actuator/busrefresh/foobar", new HashMap<>(), String.class).getStatusCode()) .isEqualTo(HttpStatus.NO_CONTENT); verify(contextRefresher, times(1)).refresh(); }