Start building against Spring Framework 5.3.0 snapshots
See gh-21929
This commit is contained in:
@@ -59,12 +59,9 @@ import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
import org.springframework.web.servlet.handler.MatchableHandlerMapping;
|
||||
import org.springframework.web.servlet.handler.RequestMatchResult;
|
||||
import org.springframework.web.servlet.mvc.condition.ConsumesRequestCondition;
|
||||
import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition;
|
||||
import org.springframework.web.servlet.mvc.condition.ProducesRequestCondition;
|
||||
import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition;
|
||||
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
|
||||
import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping;
|
||||
import org.springframework.web.util.UrlPathHelper;
|
||||
|
||||
/**
|
||||
* A custom {@link HandlerMapping} that makes {@link ExposableWebEndpoint web endpoints}
|
||||
@@ -161,7 +158,6 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
|
||||
@SuppressWarnings("deprecation")
|
||||
private static RequestMappingInfo.BuilderConfiguration getBuilderConfig() {
|
||||
RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration();
|
||||
config.setUrlPathHelper(null);
|
||||
config.setPathMatcher(null);
|
||||
config.setSuffixPatternMatch(false);
|
||||
config.setTrailingSlashMatch(true);
|
||||
@@ -195,34 +191,21 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
|
||||
}
|
||||
|
||||
private RequestMappingInfo createRequestMappingInfo(WebOperationRequestPredicate predicate, String path) {
|
||||
PatternsRequestCondition patterns = patternsRequestConditionForPattern(path);
|
||||
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);
|
||||
return RequestMappingInfo.paths(this.endpointMapping.createSubPath(path))
|
||||
.methods(RequestMethod.valueOf(predicate.getHttpMethod().name()))
|
||||
.consumes(predicate.getConsumes().toArray(new String[0]))
|
||||
.produces(predicate.getProduces().toArray(new String[0])).build();
|
||||
}
|
||||
|
||||
private void registerLinksMapping() {
|
||||
PatternsRequestCondition patterns = patternsRequestConditionForPattern("");
|
||||
RequestMethodsRequestCondition methods = new RequestMethodsRequestCondition(RequestMethod.GET);
|
||||
ProducesRequestCondition produces = new ProducesRequestCondition(this.endpointMediaTypes.getProduced()
|
||||
.toArray(StringUtils.toStringArray(this.endpointMediaTypes.getProduced())));
|
||||
RequestMappingInfo mapping = new RequestMappingInfo(patterns, methods, null, null, null, produces, null);
|
||||
RequestMappingInfo mapping = RequestMappingInfo.paths(this.endpointMapping.createSubPath(""))
|
||||
.methods(RequestMethod.GET).produces(this.endpointMediaTypes.getProduced().toArray(new String[0]))
|
||||
.options(builderConfig).build();
|
||||
LinksHandler linksHandler = getLinksHandler();
|
||||
registerMapping(mapping, linksHandler, ReflectionUtils.findMethod(linksHandler.getClass(), "links",
|
||||
HttpServletRequest.class, HttpServletResponse.class));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private PatternsRequestCondition patternsRequestConditionForPattern(String path) {
|
||||
String[] patterns = new String[] { this.endpointMapping.createSubPath(path) };
|
||||
return new PatternsRequestCondition(patterns, builderConfig.getUrlPathHelper(), builderConfig.getPathMatcher(),
|
||||
builderConfig.useSuffixPatternMatch(), builderConfig.useTrailingSlashMatch());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasCorsConfigurationSource(Object handler) {
|
||||
return this.corsConfiguration != null;
|
||||
@@ -332,7 +315,7 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
|
||||
}
|
||||
|
||||
private Object getRemainingPathSegments(HttpServletRequest request) {
|
||||
String[] pathTokens = tokenize(request, HandlerMapping.LOOKUP_PATH, true);
|
||||
String[] pathTokens = tokenize(request, UrlPathHelper.PATH_ATTRIBUTE, true);
|
||||
String[] patternTokens = tokenize(request, HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, false);
|
||||
int numberOfRemainingPathSegments = pathTokens.length - patternTokens.length + 1;
|
||||
Assert.state(numberOfRemainingPathSegments >= 0, "Unable to extract remaining path segments");
|
||||
|
||||
@@ -19,16 +19,16 @@ package org.springframework.boot.actuate.endpoint.web.servlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
/**
|
||||
* {@link HandlerInterceptorAdapter} to ensure that
|
||||
* {@link HandlerInterceptor} to ensure that
|
||||
* {@link org.springframework.web.accept.PathExtensionContentNegotiationStrategy} is
|
||||
* skipped for web endpoints.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
final class SkipPathExtensionContentNegotiation extends HandlerInterceptorAdapter {
|
||||
final class SkipPathExtensionContentNegotiation implements HandlerInterceptor {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static final String SKIP_ATTRIBUTE = org.springframework.web.accept.PathExtensionContentNegotiationStrategy.class
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -121,6 +121,13 @@ class MvcWebEndpointIntegrationTests
|
||||
context.register(TestEndpointConfiguration.class);
|
||||
context.refresh();
|
||||
WebMvcEndpointHandlerMapping bean = context.getBean(WebMvcEndpointHandlerMapping.class);
|
||||
try {
|
||||
// Trigger initLookupPath
|
||||
bean.getHandler(request);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
return bean.match(request, "/spring");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user