Commit 32102c69 authored by Andy Wilkinson's avatar Andy Wilkinson

Avoid using classes from spring-web in core web endpoint infrastructure

Closes gh-10358
parent 3fcaa976
......@@ -63,7 +63,7 @@ public class EndpointAutoConfiguration {
static class EndpointWebConfiguration {
private static final List<String> MEDIA_TYPES = Arrays
.asList(ActuatorMediaType.V2_JSON_VALUE, "application/json");
.asList(ActuatorMediaType.V2_JSON, "application/json");
private final ApplicationContext applicationContext;
......
......@@ -16,10 +16,8 @@
package org.springframework.boot.actuate.endpoint.http;
import org.springframework.http.MediaType;
/**
* {@link MediaType MediaTypes} that can be consumed and produced by Actuator endpoints.
* Media types that can be consumed and produced by Actuator endpoints.
*
* @author Andy Wilkinson
* @author Madhura Bhave
......@@ -28,24 +26,14 @@ import org.springframework.http.MediaType;
public final class ActuatorMediaType {
/**
* {@link String} equivalent of {@link #V1_JSON}.
*/
public static final String V1_JSON_VALUE = "application/vnd.spring-boot.actuator.v1+json";
/**
* {@link String} equivalent of {@link #V2_JSON}.
*/
public static final String V2_JSON_VALUE = "application/vnd.spring-boot.actuator.v2+json";
/**
* The {@code application/vnd.spring-boot.actuator.v1+json} media type.
* Constant for the Actuator V1 media type.
*/
public static final MediaType V1_JSON = MediaType.valueOf(V1_JSON_VALUE);
public static final String V1_JSON = "application/vnd.spring-boot.actuator.v1+json";
/**
* The {@code application/vnd.spring-boot.actuator.v2+json} media type.
* Constant for the Actuator V2 media type.
*/
public static final MediaType V2_JSON = MediaType.valueOf(V2_JSON_VALUE);
public static final String V2_JSON = "application/vnd.spring-boot.actuator.v2+json";
private ActuatorMediaType() {
}
......
......@@ -91,7 +91,7 @@ class JerseyEndpointsRunner extends AbstractWebEndpointRunner {
private void customize(ResourceConfig config) {
List<String> mediaTypes = Arrays.asList(MediaType.APPLICATION_JSON_VALUE,
ActuatorMediaType.V2_JSON_VALUE);
ActuatorMediaType.V2_JSON);
WebAnnotationEndpointDiscoverer discoverer = new WebAnnotationEndpointDiscoverer(
this.applicationContext,
new ConversionServiceOperationParameterMapper(), (id) -> null,
......
......@@ -98,7 +98,7 @@ class WebFluxEndpointsRunner extends AbstractWebEndpointRunner {
@Bean
public WebFluxEndpointHandlerMapping webEndpointReactiveHandlerMapping() {
List<String> mediaTypes = Arrays.asList(MediaType.APPLICATION_JSON_VALUE,
ActuatorMediaType.V2_JSON_VALUE);
ActuatorMediaType.V2_JSON);
WebAnnotationEndpointDiscoverer discoverer = new WebAnnotationEndpointDiscoverer(
this.applicationContext,
new ConversionServiceOperationParameterMapper(), (id) -> null,
......
......@@ -81,7 +81,7 @@ class WebMvcEndpointRunner extends AbstractWebEndpointRunner {
@Bean
public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping() {
List<String> mediaTypes = Arrays.asList(MediaType.APPLICATION_JSON_VALUE,
ActuatorMediaType.V2_JSON_VALUE);
ActuatorMediaType.V2_JSON);
WebAnnotationEndpointDiscoverer discoverer = new WebAnnotationEndpointDiscoverer(
this.applicationContext,
new ConversionServiceOperationParameterMapper(), (id) -> null,
......
......@@ -116,7 +116,7 @@ public class LoggersEndpointWebIntegrationTests {
@Test
public void setLoggerUsingActuatorV2JsonShouldSetLogLevel() throws Exception {
client.post().uri("/application/loggers/ROOT")
.contentType(ActuatorMediaType.V2_JSON)
.contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON))
.syncBody(Collections.singletonMap("configuredLevel", "debug")).exchange()
.expectStatus().isNoContent();
verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG);
......@@ -134,7 +134,7 @@ public class LoggersEndpointWebIntegrationTests {
@Test
public void setLoggerWithNullLogLevel() throws Exception {
client.post().uri("/application/loggers/ROOT")
.contentType(ActuatorMediaType.V2_JSON)
.contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON))
.syncBody(Collections.singletonMap("configuredLevel", null)).exchange()
.expectStatus().isNoContent();
verify(this.loggingSystem).setLogLevel("ROOT", null);
......@@ -143,8 +143,8 @@ public class LoggersEndpointWebIntegrationTests {
@Test
public void setLoggerWithNoLogLevel() throws Exception {
client.post().uri("/application/loggers/ROOT")
.contentType(ActuatorMediaType.V2_JSON).syncBody(Collections.emptyMap())
.exchange().expectStatus().isNoContent();
.contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON))
.syncBody(Collections.emptyMap()).exchange().expectStatus().isNoContent();
verify(this.loggingSystem).setLogLevel("ROOT", null);
}
......
......@@ -30,17 +30,19 @@
</subpackage>
<!-- Endpoint infrastructure -->
<subpackage name="endpoint">
<subpackage name="actuate.endpoint">
<disallow pkg="org.springframework.http" />
<disallow pkg="org.springframework.web" />
<subpackage name="web">
<allow pkg="org.springframework.http" />
<allow pkg="org.springframework.web" />
<subpackage name="mvc">
<subpackage name="servlet">
<disallow pkg="org.springframework.web.reactive" />
<allow pkg="org.springframework.http" />
<allow pkg="org.springframework.web" />
</subpackage>
<subpackage name="reactive">
<disallow pkg="org.springframework.web.servlet" />
<allow pkg="org.springframework.http" />
<allow pkg="org.springframework.web" />
</subpackage>
</subpackage>
</subpackage>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment