Fix failing test (after previous commit)

master
Rossen Stoyanchev 7 years ago
parent 97917aa57d
commit 53e8ebe6a6
  1. 4
      spring-web/src/main/java/org/springframework/http/server/reactive/DefaultPathSegmentContainer.java
  2. 3
      spring-web/src/test/java/org/springframework/http/server/reactive/DefaultRequestPathTests.java

@ -190,10 +190,14 @@ class DefaultPathSegmentContainer implements PathSegmentContainer {
}
static PathSegmentContainer subPath(PathSegmentContainer container, int fromIndex, int toIndex) {
if (fromIndex == toIndex) {
return EMPTY_PATH;
}
List<PathSegment> segments = container.pathSegments();
if (fromIndex == 0 && toIndex == segments.size()) {
return container;
}
Assert.isTrue(fromIndex < toIndex, "fromIndex: " + fromIndex + " should be < toIndex " + toIndex);
Assert.isTrue(fromIndex >= 0 && fromIndex < segments.size(), "Invalid fromIndex: " + fromIndex);
Assert.isTrue(toIndex >= 0 && toIndex <= segments.size(), "Invalid toIndex: " + toIndex);

@ -36,6 +36,9 @@ public class DefaultRequestPathTests {
// no context path
testRequestPath("/a/b/c", "", "/a/b/c", false, true, false);
// context path only
testRequestPath("/a/b", "/a/b", "", false, true, false);
// empty path
testRequestPath("", "", "", true, false, false);
testRequestPath("", "/", "", true, false, false);

Loading…
Cancel
Save