Remove statusCode state tracking

Closes gh-23490
This commit is contained in:
Rossen Stoyanchev
2019-08-21 11:45:56 +03:00
parent e1158ad5cb
commit 78abc27432
2 changed files with 6 additions and 21 deletions

View File

@@ -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();

View File

@@ -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();
}
/**