diff --git a/spring-web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java b/spring-web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java index c052e391917..1e9cf29aec9 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.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. @@ -112,7 +112,7 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter { WebUtils.getNativeResponse(response, ContentCachingResponseWrapper.class); Assert.notNull(responseWrapper, "ContentCachingResponseWrapper not found"); HttpServletResponse rawResponse = (HttpServletResponse) responseWrapper.getResponse(); - int statusCode = responseWrapper.getStatusCode(); + int statusCode = responseWrapper.getStatus(); if (rawResponse.isCommitted()) { responseWrapper.copyBodyToResponse(); diff --git a/spring-web/src/main/java/org/springframework/web/util/ContentCachingResponseWrapper.java b/spring-web/src/main/java/org/springframework/web/util/ContentCachingResponseWrapper.java index 5d70252aac1..3161b5fd8c5 100644 --- a/spring-web/src/main/java/org/springframework/web/util/ContentCachingResponseWrapper.java +++ b/spring-web/src/main/java/org/springframework/web/util/ContentCachingResponseWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 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. @@ -51,8 +51,6 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper { @Nullable private PrintWriter writer; - private int statusCode = HttpServletResponse.SC_OK; - @Nullable private Integer contentLength; @@ -66,19 +64,6 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper { } - @Override - public void setStatus(int sc) { - super.setStatus(sc); - this.statusCode = sc; - } - - @SuppressWarnings("deprecation") - @Override - public void setStatus(int sc, String sm) { - super.setStatus(sc, sm); - this.statusCode = sc; - } - @Override public void sendError(int sc) throws IOException { copyBodyToResponse(false); @@ -89,7 +74,6 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper { // Possibly on Tomcat when called too late: fall back to silent setStatus super.setStatus(sc); } - this.statusCode = sc; } @Override @@ -103,7 +87,6 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper { // Possibly on Tomcat when called too late: fall back to silent setStatus super.setStatus(sc, msg); } - this.statusCode = sc; } @Override @@ -176,9 +159,11 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper { /** * Return the status code as specified on the response. + * @deprecated as of 5.2 in favor of {@link HttpServletResponse#getStatus()} */ + @Deprecated public int getStatusCode() { - return this.statusCode; + return getStatus(); } /**