diff --git a/org.springframework.web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java b/org.springframework.web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java index a05e05c350d..8cd8494b415 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java +++ b/org.springframework.web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java @@ -113,8 +113,9 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter { } /** - * Generate the ETag header value from the given response body byte array.
The default implementation generates an - * MD5 hash. + * Generate the ETag header value from the given response body byte array. + * + *
The default implementation generates an MD5 hash. * * @param bytes the response bdoy as byte array * @return the ETag header value @@ -140,7 +141,7 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter { private PrintWriter writer; - private int statusCode = -1; + private int statusCode = HttpServletResponse.SC_OK; private ShallowEtagResponseWrapper(HttpServletResponse response) { super(response); diff --git a/org.springframework.web/src/test/java/org/springframework/web/filter/ShallowEtagHeaderFilterTest.java b/org.springframework.web/src/test/java/org/springframework/web/filter/ShallowEtagHeaderFilterTests.java similarity index 97% rename from org.springframework.web/src/test/java/org/springframework/web/filter/ShallowEtagHeaderFilterTest.java rename to org.springframework.web/src/test/java/org/springframework/web/filter/ShallowEtagHeaderFilterTests.java index a3f56ecfbb9..b5913291132 100644 --- a/org.springframework.web/src/test/java/org/springframework/web/filter/ShallowEtagHeaderFilterTest.java +++ b/org.springframework.web/src/test/java/org/springframework/web/filter/ShallowEtagHeaderFilterTests.java @@ -31,7 +31,7 @@ import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.util.FileCopyUtils; -public class ShallowEtagHeaderFilterTest { +public class ShallowEtagHeaderFilterTests { private ShallowEtagHeaderFilter filter; @@ -85,7 +85,6 @@ public class ShallowEtagHeaderFilterTest { public void doFilter(ServletRequest filterRequest, ServletResponse filterResponse) throws IOException, ServletException { assertEquals("Invalid request passed", request, filterRequest); - ((HttpServletResponse) filterResponse).setStatus(HttpServletResponse.SC_OK); byte[] responseBody = "Hello World".getBytes("UTF-8"); FileCopyUtils.copy(responseBody, filterResponse.getOutputStream()); }