Skip to content

Commit 78abc27

Browse files
committed
Remove statusCode state tracking
Closes gh-23490
1 parent e1158ad commit 78abc27

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -112,7 +112,7 @@ private void updateResponse(HttpServletRequest request, HttpServletResponse resp
112112
WebUtils.getNativeResponse(response, ContentCachingResponseWrapper.class);
113113
Assert.notNull(responseWrapper, "ContentCachingResponseWrapper not found");
114114
HttpServletResponse rawResponse = (HttpServletResponse) responseWrapper.getResponse();
115-
int statusCode = responseWrapper.getStatusCode();
115+
int statusCode = responseWrapper.getStatus();
116116

117117
if (rawResponse.isCommitted()) {
118118
responseWrapper.copyBodyToResponse();

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

+4-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -51,8 +51,6 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper {
5151
@Nullable
5252
private PrintWriter writer;
5353

54-
private int statusCode = HttpServletResponse.SC_OK;
55-
5654
@Nullable
5755
private Integer contentLength;
5856

@@ -66,19 +64,6 @@ public ContentCachingResponseWrapper(HttpServletResponse response) {
6664
}
6765

6866

69-
@Override
70-
public void setStatus(int sc) {
71-
super.setStatus(sc);
72-
this.statusCode = sc;
73-
}
74-
75-
@SuppressWarnings("deprecation")
76-
@Override
77-
public void setStatus(int sc, String sm) {
78-
super.setStatus(sc, sm);
79-
this.statusCode = sc;
80-
}
81-
8267
@Override
8368
public void sendError(int sc) throws IOException {
8469
copyBodyToResponse(false);
@@ -89,7 +74,6 @@ public void sendError(int sc) throws IOException {
8974
// Possibly on Tomcat when called too late: fall back to silent setStatus
9075
super.setStatus(sc);
9176
}
92-
this.statusCode = sc;
9377
}
9478

9579
@Override
@@ -103,7 +87,6 @@ public void sendError(int sc, String msg) throws IOException {
10387
// Possibly on Tomcat when called too late: fall back to silent setStatus
10488
super.setStatus(sc, msg);
10589
}
106-
this.statusCode = sc;
10790
}
10891

10992
@Override
@@ -176,9 +159,11 @@ public void reset() {
176159

177160
/**
178161
* Return the status code as specified on the response.
162+
* @deprecated as of 5.2 in favor of {@link HttpServletResponse#getStatus()}
179163
*/
164+
@Deprecated
180165
public int getStatusCode() {
181-
return this.statusCode;
166+
return getStatus();
182167
}
183168

184169
/**

0 commit comments

Comments
 (0)