Deprecate and set trailingSlash option to false
Closes gh-28552
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -110,7 +110,7 @@ public class WebFluxConfigurationSupportTests {
|
||||
PathPatternParser patternParser = mapping.getPathPatternParser();
|
||||
assertThat(patternParser).isNotNull();
|
||||
boolean matchOptionalTrailingSlash = (boolean) ReflectionUtils.getField(field, patternParser);
|
||||
assertThat(matchOptionalTrailingSlash).isTrue();
|
||||
assertThat(matchOptionalTrailingSlash).isFalse();
|
||||
|
||||
name = "webFluxContentTypeResolver";
|
||||
RequestedContentTypeResolver resolver = context.getBean(name, RequestedContentTypeResolver.class);
|
||||
@@ -124,18 +124,11 @@ public class WebFluxConfigurationSupportTests {
|
||||
@Test
|
||||
public void customPathMatchConfig() {
|
||||
ApplicationContext context = loadConfig(CustomPatchMatchConfig.class);
|
||||
final Field field = ReflectionUtils.findField(PathPatternParser.class, "matchOptionalTrailingSeparator");
|
||||
ReflectionUtils.makeAccessible(field);
|
||||
|
||||
String name = "requestMappingHandlerMapping";
|
||||
RequestMappingHandlerMapping mapping = context.getBean(name, RequestMappingHandlerMapping.class);
|
||||
assertThat(mapping).isNotNull();
|
||||
|
||||
PathPatternParser patternParser = mapping.getPathPatternParser();
|
||||
assertThat(patternParser).isNotNull();
|
||||
boolean matchOptionalTrailingSlash = (boolean) ReflectionUtils.getField(field, patternParser);
|
||||
assertThat(matchOptionalTrailingSlash).isFalse();
|
||||
|
||||
Map<RequestMappingInfo, HandlerMethod> map = mapping.getHandlerMethods();
|
||||
assertThat(map.size()).isEqualTo(1);
|
||||
assertThat(map.keySet().iterator().next().getPatternsCondition().getPatterns())
|
||||
@@ -323,7 +316,6 @@ public class WebFluxConfigurationSupportTests {
|
||||
|
||||
@Override
|
||||
public void configurePathMatching(PathMatchConfigurer configurer) {
|
||||
configurer.setUseTrailingSlashMatch(false);
|
||||
configurer.addPathPrefix("/api", HandlerTypePredicate.forAnnotation(RestController.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -56,7 +56,6 @@ public class SimpleUrlHandlerMappingTests {
|
||||
|
||||
testUrl("/welcome.html", mainController, handlerMapping, "");
|
||||
testUrl("/welcome.x", otherController, handlerMapping, "welcome.x");
|
||||
testUrl("/welcome/", otherController, handlerMapping, "welcome");
|
||||
testUrl("/show.html", mainController, handlerMapping, "");
|
||||
testUrl("/bookseats.html", mainController, handlerMapping, "");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -107,10 +107,14 @@ public class PatternsRequestConditionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void matchTrailingSlash() {
|
||||
MockServerWebExchange exchange = MockServerWebExchange.from(get("/foo/"));
|
||||
|
||||
PatternsRequestCondition condition = createPatternsCondition("/foo");
|
||||
PathPatternParser patternParser = new PathPatternParser();
|
||||
patternParser.setMatchOptionalTrailingSeparator(true);
|
||||
|
||||
PatternsRequestCondition condition = new PatternsRequestCondition(patternParser.parse("/foo"));
|
||||
PatternsRequestCondition match = condition.getMatchingCondition(exchange);
|
||||
|
||||
assertThat(match).isNotNull();
|
||||
@@ -118,7 +122,7 @@ public class PatternsRequestConditionTests {
|
||||
.as("Should match by default")
|
||||
.isEqualTo("/foo");
|
||||
|
||||
condition = createPatternsCondition("/foo");
|
||||
condition = new PatternsRequestCondition(patternParser.parse("/foo"));
|
||||
match = condition.getMatchingCondition(exchange);
|
||||
|
||||
assertThat(match).isNotNull();
|
||||
|
||||
@@ -119,10 +119,6 @@ public class RequestMappingInfoHandlerMappingTests {
|
||||
ServerWebExchange exchange = MockServerWebExchange.from(get(""));
|
||||
HandlerMethod hm = (HandlerMethod) this.handlerMapping.getHandler(exchange).block();
|
||||
assertThat(hm.getMethod()).isEqualTo(expected);
|
||||
|
||||
exchange = MockServerWebExchange.from(get("/"));
|
||||
hm = (HandlerMethod) this.handlerMapping.getHandler(exchange).block();
|
||||
assertThat(hm.getMethod()).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -157,7 +153,6 @@ public class RequestMappingInfoHandlerMappingTests {
|
||||
@Test // SPR-8462
|
||||
public void getHandlerMediaTypeNotSupported() {
|
||||
testHttpMediaTypeNotSupportedException("/person/1");
|
||||
testHttpMediaTypeNotSupportedException("/person/1/");
|
||||
testHttpMediaTypeNotSupportedException("/person/1.json");
|
||||
}
|
||||
|
||||
@@ -175,7 +170,6 @@ public class RequestMappingInfoHandlerMappingTests {
|
||||
@Test // SPR-8462
|
||||
public void getHandlerTestMediaTypeNotAcceptable() {
|
||||
testMediaTypeNotAcceptable("/persons");
|
||||
testMediaTypeNotAcceptable("/persons/");
|
||||
}
|
||||
|
||||
@Test // SPR-12854
|
||||
|
||||
Reference in New Issue
Block a user