diff --git a/build.gradle b/build.gradle index 87cb8892823..aafb9a6c5e8 100644 --- a/build.gradle +++ b/build.gradle @@ -46,7 +46,7 @@ ext { rxjava2Version = "2.2.7" slf4jVersion = "1.7.26" // spring-jcl + consistent 3rd party deps tiles3Version = "3.0.8" - tomcatVersion = "9.0.16" + tomcatVersion = "9.0.17" undertowVersion = "2.0.19.Final" gradleScriptDir = "${rootProject.projectDir}/gradle" diff --git a/spring-core/src/main/java/org/springframework/util/StringUtils.java b/spring-core/src/main/java/org/springframework/util/StringUtils.java index 093fa9d404c..11e33cbbce1 100644 --- a/spring-core/src/main/java/org/springframework/util/StringUtils.java +++ b/spring-core/src/main/java/org/springframework/util/StringUtils.java @@ -780,7 +780,9 @@ public abstract class StringUtils { if (tokens.length == 1) { validateLocalePart(localeValue); Locale resolved = Locale.forLanguageTag(localeValue); - return (resolved.getLanguage().length() > 0 ? resolved : null); + if (resolved.getLanguage().length() > 0) { + return resolved; + } } return parseLocaleTokens(localeValue, tokens); } diff --git a/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java b/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java index ab0e294d214..8b77c0b2717 100644 --- a/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -765,4 +765,20 @@ public class StringUtilsTests { } } + @Test + public void testInvalidLocaleWithLocaleString() { + assertEquals(new Locale("invalid"), StringUtils.parseLocaleString("invalid")); + assertEquals(new Locale("invalidvalue"), StringUtils.parseLocaleString("invalidvalue")); + assertEquals(new Locale("invalidvalue", "foo"), StringUtils.parseLocaleString("invalidvalue_foo")); + assertNull(StringUtils.parseLocaleString("")); + } + + @Test + public void testInvalidLocaleWithLanguageTag() { + assertEquals(new Locale("invalid"), StringUtils.parseLocale("invalid")); + assertEquals(new Locale("invalidvalue"), StringUtils.parseLocale("invalidvalue")); + assertEquals(new Locale("invalidvalue", "foo"), StringUtils.parseLocale("invalidvalue_foo")); + assertNull(StringUtils.parseLocale("")); + } + } diff --git a/spring-web/spring-web.gradle b/spring-web/spring-web.gradle index 03bad1cb077..f9e063b98bb 100644 --- a/spring-web/spring-web.gradle +++ b/spring-web/spring-web.gradle @@ -38,7 +38,7 @@ dependencies { exclude group: "javax.servlet", module: "javax.servlet-api" } optional("org.eclipse.jetty:jetty-reactive-httpclient:1.0.2") - optional("com.squareup.okhttp3:okhttp:3.13.1") + optional("com.squareup.okhttp3:okhttp:3.14.0") optional("org.apache.httpcomponents:httpclient:4.5.7") { exclude group: "commons-logging", module: "commons-logging" } @@ -75,7 +75,7 @@ dependencies { testCompile("org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}") testCompile("org.eclipse.jetty:jetty-server") testCompile("org.eclipse.jetty:jetty-servlet") - testCompile("com.squareup.okhttp3:mockwebserver:3.13.1") + testCompile("com.squareup.okhttp3:mockwebserver:3.14.0") testCompile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}") testCompile("org.skyscreamer:jsonassert:1.5.0") testCompile("org.xmlunit:xmlunit-matchers:2.6.2") diff --git a/spring-webflux/spring-webflux.gradle b/spring-webflux/spring-webflux.gradle index 90f0f883985..3d8c26f1bc9 100644 --- a/spring-webflux/spring-webflux.gradle +++ b/spring-webflux/spring-webflux.gradle @@ -53,7 +53,7 @@ dependencies { testCompile("org.eclipse.jetty:jetty-server") testCompile("org.eclipse.jetty:jetty-servlet") testCompile("org.eclipse.jetty:jetty-reactive-httpclient:1.0.2") - testCompile("com.squareup.okhttp3:mockwebserver:3.13.1") + testCompile("com.squareup.okhttp3:mockwebserver:3.14.0") testCompile("org.jetbrains.kotlin:kotlin-script-runtime:${kotlinVersion}") testRuntime("org.jetbrains.kotlin:kotlin-script-util:${kotlinVersion}") testRuntime("org.jetbrains.kotlin:kotlin-compiler:${kotlinVersion}") diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java index 0710ab65ec5..40e269194cb 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -446,7 +446,7 @@ public abstract class ResponseEntityExceptionHandler { } /** - * A single place to customize the response body of all Exception types. + * A single place to customize the response body of all exception types. *
The default implementation sets the {@link WebUtils#ERROR_EXCEPTION_ATTRIBUTE} * request attribute and creates a {@link ResponseEntity} from the given * body, headers, and status.