Ignore null Locale in MockHttpServletResponse
Prior to this commit, calls to setLocale() MockHttpServletResponse would result in a NullPointerException if the supplied Locale was null. Although the Javadoc for setLocale(Locale) and addHeader(String, String) in javax.servlet.ServletResponse does not specify how a null Locale should be handled, both Tomcat and Jetty simply ignore a null value. This commit therefore updates MockHttpServletResponse to silently ignore a null Locale passed to setLocale(). Closes gh-26493
This commit is contained in:
@@ -85,6 +85,13 @@ class MockHttpServletResponseTests {
|
||||
assertThat(response.containsHeader(headerName)).isFalse();
|
||||
}
|
||||
|
||||
@Test // gh-26493
|
||||
void setLocaleWithNullValue() {
|
||||
assertThat(response.getLocale()).isEqualTo(Locale.getDefault());
|
||||
response.setLocale(null);
|
||||
assertThat(response.getLocale()).isEqualTo(Locale.getDefault());
|
||||
}
|
||||
|
||||
@Test
|
||||
void setContentType() {
|
||||
String contentType = "test/plain";
|
||||
|
||||
Reference in New Issue
Block a user