From 634dd979d1e8f5ebebd668f8a1b7430b1c18b56e Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Wed, 27 Jan 2021 07:34:15 +0100 Subject: [PATCH 1/2] Migrate from deprecated methods in AbstractWebFluxEndpointHandlerMapping See gh-25006 --- ...AbstractWebFluxEndpointHandlerMapping.java | 33 +++++-------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java index 3d47584dd9..97e287b0cb 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java @@ -59,15 +59,10 @@ import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.method.HandlerMethod; import org.springframework.web.reactive.HandlerMapping; -import org.springframework.web.reactive.result.condition.ConsumesRequestCondition; -import org.springframework.web.reactive.result.condition.PatternsRequestCondition; -import org.springframework.web.reactive.result.condition.ProducesRequestCondition; -import org.springframework.web.reactive.result.condition.RequestMethodsRequestCondition; import org.springframework.web.reactive.result.method.RequestMappingInfo; import org.springframework.web.reactive.result.method.RequestMappingInfoHandlerMapping; import org.springframework.web.server.ResponseStatusException; import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.util.pattern.PathPatternParser; /** * A custom {@link HandlerMapping} that makes web endpoints available over HTTP using @@ -81,8 +76,6 @@ import org.springframework.web.util.pattern.PathPatternParser; */ public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappingInfoHandlerMapping { - private static final PathPatternParser pathPatternParser = new PathPatternParser(); - private final EndpointMapping endpointMapping; private final Collection endpoints; @@ -163,28 +156,20 @@ public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappi return reactiveWebOperation; } - @SuppressWarnings("deprecation") private RequestMappingInfo createRequestMappingInfo(WebOperation operation) { WebOperationRequestPredicate predicate = operation.getRequestPredicate(); - PatternsRequestCondition patterns = new PatternsRequestCondition( - pathPatternParser.parse(this.endpointMapping.createSubPath(predicate.getPath()))); - RequestMethodsRequestCondition methods = new RequestMethodsRequestCondition( - RequestMethod.valueOf(predicate.getHttpMethod().name())); - ConsumesRequestCondition consumes = new ConsumesRequestCondition( - StringUtils.toStringArray(predicate.getConsumes())); - ProducesRequestCondition produces = new ProducesRequestCondition( - StringUtils.toStringArray(predicate.getProduces())); - return new RequestMappingInfo(null, patterns, methods, null, null, consumes, produces, null); + String path = this.endpointMapping.createSubPath(predicate.getPath()); + RequestMethod method = RequestMethod.valueOf(predicate.getHttpMethod().name()); + String[] consumes = StringUtils.toStringArray(predicate.getConsumes()); + String[] produces = StringUtils.toStringArray(predicate.getProduces()); + return RequestMappingInfo.paths(path).methods(method).consumes(consumes).produces(produces).build(); } - @SuppressWarnings("deprecation") private void registerLinksMapping() { - PatternsRequestCondition patterns = new PatternsRequestCondition( - pathPatternParser.parse(this.endpointMapping.getPath())); - RequestMethodsRequestCondition methods = new RequestMethodsRequestCondition(RequestMethod.GET); - ProducesRequestCondition produces = new ProducesRequestCondition( - StringUtils.toStringArray(this.endpointMediaTypes.getProduced())); - RequestMappingInfo mapping = new RequestMappingInfo(patterns, methods, null, null, null, produces, null); + String path = this.endpointMapping.getPath(); + String[] produces = StringUtils.toStringArray(this.endpointMediaTypes.getProduced()); + RequestMethod method = RequestMethod.GET; + RequestMappingInfo mapping = RequestMappingInfo.paths(path).methods(method).produces(produces).build(); LinksHandler linksHandler = getLinksHandler(); registerMapping(mapping, linksHandler, ReflectionUtils.findMethod(linksHandler.getClass(), "links", ServerWebExchange.class)); From 948f61b4cab1b15e0283b9f2d876a0c4893e92fe Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 9 Feb 2021 09:10:56 +0100 Subject: [PATCH 2/2] Polish contribution See gh-25006 --- .../web/reactive/AbstractWebFluxEndpointHandlerMapping.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java index 97e287b0cb..b7501b87a8 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java @@ -168,8 +168,8 @@ public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappi private void registerLinksMapping() { String path = this.endpointMapping.getPath(); String[] produces = StringUtils.toStringArray(this.endpointMediaTypes.getProduced()); - RequestMethod method = RequestMethod.GET; - RequestMappingInfo mapping = RequestMappingInfo.paths(path).methods(method).produces(produces).build(); + RequestMappingInfo mapping = RequestMappingInfo.paths(path).methods(RequestMethod.GET).produces(produces) + .build(); LinksHandler linksHandler = getLinksHandler(); registerMapping(mapping, linksHandler, ReflectionUtils.findMethod(linksHandler.getClass(), "links", ServerWebExchange.class));