Merge branch '5.1.x'

This commit is contained in:
Juergen Hoeller 2019-04-08 20:19:03 +02:00
commit c8609b83b6
4 changed files with 32 additions and 37 deletions

View File

@ -47,7 +47,7 @@ ext {
slf4jVersion = "1.7.26" // spring-jcl + consistent 3rd party deps slf4jVersion = "1.7.26" // spring-jcl + consistent 3rd party deps
tiles3Version = "3.0.8" tiles3Version = "3.0.8"
tomcatVersion = "9.0.17" tomcatVersion = "9.0.17"
undertowVersion = "2.0.19.Final" undertowVersion = "2.0.20.Final"
gradleScriptDir = "${rootProject.projectDir}/gradle" gradleScriptDir = "${rootProject.projectDir}/gradle"
withoutJclOverSlf4J = { withoutJclOverSlf4J = {
@ -143,7 +143,7 @@ configure(allprojects) { project ->
} }
checkstyle { checkstyle {
toolVersion = "8.18" toolVersion = "8.19"
configDir = rootProject.file("src/checkstyle") configDir = rootProject.file("src/checkstyle")
} }
@ -157,7 +157,7 @@ configure(allprojects) { project ->
testCompile("junit:junit:4.12") { testCompile("junit:junit:4.12") {
exclude group: "org.hamcrest", module: "hamcrest-core" exclude group: "org.hamcrest", module: "hamcrest-core"
} }
testCompile("org.mockito:mockito-core:2.25.1") { testCompile("org.mockito:mockito-core:2.26.0") {
exclude group: "org.hamcrest", module: "hamcrest-core" exclude group: "org.hamcrest", module: "hamcrest-core"
} }
testCompile("io.mockk:mockk:1.9.1") testCompile("io.mockk:mockk:1.9.1")

View File

@ -170,8 +170,7 @@ public abstract class HttpRange {
* @param ranges the list of ranges * @param ranges the list of ranges
* @param resource the resource to select the regions from * @param resource the resource to select the regions from
* @return the list of regions for the given resource * @return the list of regions for the given resource
* @throws IllegalArgumentException if the sum of all ranges exceeds the * @throws IllegalArgumentException if the sum of all ranges exceeds the resource length
* resource length.
* @since 4.3 * @since 4.3
*/ */
public static List<ResourceRegion> toResourceRegions(List<HttpRange> ranges, Resource resource) { public static List<ResourceRegion> toResourceRegions(List<HttpRange> ranges, Resource resource) {
@ -184,7 +183,10 @@ public abstract class HttpRange {
} }
if (ranges.size() > 1) { if (ranges.size() > 1) {
long length = getLengthFor(resource); long length = getLengthFor(resource);
long total = regions.stream().map(ResourceRegion::getCount).reduce(0L, (count, sum) -> sum + count); long total = 0;
for (ResourceRegion region : regions) {
total += region.getCount();
}
if (total >= length) { if (total >= length) {
throw new IllegalArgumentException("The sum of all ranges (" + total + throw new IllegalArgumentException("The sum of all ranges (" + total +
") should be less than the resource length (" + length + ")"); ") should be less than the resource length (" + length + ")");

View File

@ -21,7 +21,6 @@ import java.nio.charset.UnsupportedCharsetException;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -34,7 +33,7 @@ import org.springframework.util.StringUtils;
/** /**
* Helper class for URL path matching. Provides support for URL paths in * Helper class for URL path matching. Provides support for URL paths in
* RequestDispatcher includes and support for consistent URL decoding. * {@code RequestDispatcher} includes and support for consistent URL decoding.
* *
* <p>Used by {@link org.springframework.web.servlet.handler.AbstractUrlHandlerMapping} * <p>Used by {@link org.springframework.web.servlet.handler.AbstractUrlHandlerMapping}
* and {@link org.springframework.web.servlet.support.RequestContext} for path matching * and {@link org.springframework.web.servlet.support.RequestContext} for path matching
@ -44,6 +43,8 @@ import org.springframework.util.StringUtils;
* @author Rob Harrop * @author Rob Harrop
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 14.01.2004 * @since 14.01.2004
* @see #getLookupPathForRequest
* @see javax.servlet.RequestDispatcher
*/ */
public class UrlPathHelper { public class UrlPathHelper {
@ -70,8 +71,9 @@ public class UrlPathHelper {
/** /**
* Whether URL lookups should always use the full path within current * Whether URL lookups should always use the full path within the current
* application context, i.e. within {@link ServletContext#getContextPath()}. * web application context, i.e. within
* {@link javax.servlet.ServletContext#getContextPath()}.
* <p>If set to {@literal false} the path within the current servlet mapping * <p>If set to {@literal false} the path within the current servlet mapping
* is used instead if applicable (i.e. in the case of a prefix based Servlet * is used instead if applicable (i.e. in the case of a prefix based Servlet
* mapping such as "/myServlet/*"). * mapping such as "/myServlet/*").
@ -157,8 +159,8 @@ public class UrlPathHelper {
* <p>Detects include request URL if called within a RequestDispatcher include. * <p>Detects include request URL if called within a RequestDispatcher include.
* @param request current HTTP request * @param request current HTTP request
* @return the lookup path * @return the lookup path
* @see #getPathWithinApplication
* @see #getPathWithinServletMapping * @see #getPathWithinServletMapping
* @see #getPathWithinApplication
*/ */
public String getLookupPathForRequest(HttpServletRequest request) { public String getLookupPathForRequest(HttpServletRequest request) {
// Always use full path within current servlet context? // Always use full path within current servlet context?
@ -207,6 +209,7 @@ public class UrlPathHelper {
* <p>E.g.: servlet mapping = "/*.test"; request URI = "/a.test" -> "". * <p>E.g.: servlet mapping = "/*.test"; request URI = "/a.test" -> "".
* @param request current HTTP request * @param request current HTTP request
* @return the path within the servlet mapping, or "" * @return the path within the servlet mapping, or ""
* @see #getLookupPathForRequest
*/ */
public String getPathWithinServletMapping(HttpServletRequest request) { public String getPathWithinServletMapping(HttpServletRequest request) {
String pathWithinApp = getPathWithinApplication(request); String pathWithinApp = getPathWithinApplication(request);
@ -254,6 +257,7 @@ public class UrlPathHelper {
* <p>Detects include request URL if called within a RequestDispatcher include. * <p>Detects include request URL if called within a RequestDispatcher include.
* @param request current HTTP request * @param request current HTTP request
* @return the path within the web application * @return the path within the web application
* @see #getLookupPathForRequest
*/ */
public String getPathWithinApplication(HttpServletRequest request) { public String getPathWithinApplication(HttpServletRequest request) {
String contextPath = getContextPath(request); String contextPath = getContextPath(request);
@ -512,8 +516,8 @@ public class UrlPathHelper {
/** /**
* Remove ";" (semicolon) content from the given request URI if the * Remove ";" (semicolon) content from the given request URI if the
* {@linkplain #setRemoveSemicolonContent(boolean) removeSemicolonContent} * {@linkplain #setRemoveSemicolonContent removeSemicolonContent}
* property is set to "true". Note that "jssessionid" is always removed. * property is set to "true". Note that "jsessionid" is always removed.
* @param requestUri the request URI string to remove ";" content from * @param requestUri the request URI string to remove ";" content from
* @return the updated URI string * @return the updated URI string
*/ */
@ -544,12 +548,10 @@ public class UrlPathHelper {
} }
/** /**
* Decode the given URI path variables via * Decode the given URI path variables via {@link #decodeRequestString} unless
* {@link #decodeRequestString(HttpServletRequest, String)} unless * {@link #setUrlDecode} is set to {@code true} in which case it is assumed
* {@link #setUrlDecode(boolean)} is set to {@code true} in which case it is * the URL path from which the variables were extracted is already decoded
* assumed the URL path from which the variables were extracted is already * through a call to {@link #getLookupPathForRequest(HttpServletRequest)}.
* decoded through a call to
* {@link #getLookupPathForRequest(HttpServletRequest)}.
* @param request current HTTP request * @param request current HTTP request
* @param vars the URI variables extracted from the URL path * @param vars the URI variables extracted from the URL path
* @return the same Map or a new Map instance * @return the same Map or a new Map instance
@ -566,18 +568,16 @@ public class UrlPathHelper {
} }
/** /**
* Decode the given matrix variables via * Decode the given matrix variables via {@link #decodeRequestString} unless
* {@link #decodeRequestString(HttpServletRequest, String)} unless * {@link #setUrlDecode} is set to {@code true} in which case it is assumed
* {@link #setUrlDecode(boolean)} is set to {@code true} in which case it is * the URL path from which the variables were extracted is already decoded
* assumed the URL path from which the variables were extracted is already * through a call to {@link #getLookupPathForRequest(HttpServletRequest)}.
* decoded through a call to
* {@link #getLookupPathForRequest(HttpServletRequest)}.
* @param request current HTTP request * @param request current HTTP request
* @param vars the URI variables extracted from the URL path * @param vars the URI variables extracted from the URL path
* @return the same Map or a new Map instance * @return the same Map or a new Map instance
*/ */
public MultiValueMap<String, String> decodeMatrixVariables(HttpServletRequest request, public MultiValueMap<String, String> decodeMatrixVariables(
MultiValueMap<String, String> vars) { HttpServletRequest request, MultiValueMap<String, String> vars) {
if (this.urlDecode) { if (this.urlDecode) {
return vars; return vars;

View File

@ -83,15 +83,8 @@ import org.junit.Test;
import org.springframework.beans.FatalBeanException; import org.springframework.beans.FatalBeanException;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.not; import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/** /**
* Test class for {@link Jackson2ObjectMapperBuilder}. * Test class for {@link Jackson2ObjectMapperBuilder}.