Browse Source

Remove statusCode state tracking

Closes gh-23490
pull/23506/head
Rossen Stoyanchev 7 years ago
parent
commit
78abc27432
  1. 4
      spring-web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java
  2. 23
      spring-web/src/main/java/org/springframework/web/util/ContentCachingResponseWrapper.java

4
spring-web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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();

23
spring-web/src/main/java/org/springframework/web/util/ContentCachingResponseWrapper.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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();
}
/**

Loading…
Cancel
Save