Skip to content

Commit 83c020e

Browse files
committed
Remove deprecated HttpStatus codes
See gh-33809
1 parent 9f77d5f commit 83c020e

File tree

3 files changed

+0
-171
lines changed

3 files changed

+0
-171
lines changed

spring-test/src/main/java/org/springframework/test/web/servlet/result/StatusResultMatchers.java

-66
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,6 @@ public ResultMatcher isFound() {
255255
return matcher(HttpStatus.FOUND);
256256
}
257257

258-
/**
259-
* Assert the response status code is {@code HttpStatus.MOVED_TEMPORARILY} (302).
260-
* @see #isFound()
261-
* @deprecated in favor of {@link #isFound()}
262-
*/
263-
@Deprecated
264-
public ResultMatcher isMovedTemporarily() {
265-
return matcher(HttpStatus.MOVED_TEMPORARILY);
266-
}
267-
268258
/**
269259
* Assert the response status code is {@code HttpStatus.SEE_OTHER} (303).
270260
*/
@@ -279,15 +269,6 @@ public ResultMatcher isNotModified() {
279269
return matcher(HttpStatus.NOT_MODIFIED);
280270
}
281271

282-
/**
283-
* Assert the response status code is {@code HttpStatus.USE_PROXY} (305).
284-
* @deprecated matching the deprecation of {@code HttpStatus.USE_PROXY}
285-
*/
286-
@Deprecated
287-
public ResultMatcher isUseProxy() {
288-
return matcher(HttpStatus.USE_PROXY);
289-
}
290-
291272
/**
292273
* Assert the response status code is {@code HttpStatus.TEMPORARY_REDIRECT} (307).
293274
*/
@@ -401,16 +382,6 @@ public ResultMatcher isPayloadTooLarge() {
401382
return matcher(HttpStatus.PAYLOAD_TOO_LARGE);
402383
}
403384

404-
/**
405-
* Assert the response status code is {@code HttpStatus.REQUEST_ENTITY_TOO_LARGE} (413).
406-
* @see #isPayloadTooLarge()
407-
* @deprecated matching the deprecation of {@code HttpStatus.REQUEST_ENTITY_TOO_LARGE}
408-
*/
409-
@Deprecated
410-
public ResultMatcher isRequestEntityTooLarge() {
411-
return matcher(HttpStatus.REQUEST_ENTITY_TOO_LARGE);
412-
}
413-
414385
/**
415386
* Assert the response status code is {@code HttpStatus.REQUEST_URI_TOO_LONG} (414).
416387
* @since 4.1
@@ -419,16 +390,6 @@ public ResultMatcher isUriTooLong() {
419390
return matcher(HttpStatus.URI_TOO_LONG);
420391
}
421392

422-
/**
423-
* Assert the response status code is {@code HttpStatus.REQUEST_URI_TOO_LONG} (414).
424-
* @see #isUriTooLong()
425-
* @deprecated matching the deprecation of {@code HttpStatus.REQUEST_URI_TOO_LONG}
426-
*/
427-
@Deprecated
428-
public ResultMatcher isRequestUriTooLong() {
429-
return matcher(HttpStatus.REQUEST_URI_TOO_LONG);
430-
}
431-
432393
/**
433394
* Assert the response status code is {@code HttpStatus.UNSUPPORTED_MEDIA_TYPE} (415).
434395
*/
@@ -457,33 +418,6 @@ public ResultMatcher isIAmATeapot() {
457418
return matcher(HttpStatus.valueOf(418));
458419
}
459420

460-
/**
461-
* Assert the response status code is {@code HttpStatus.INSUFFICIENT_SPACE_ON_RESOURCE} (419).
462-
* @deprecated matching the deprecation of {@code HttpStatus.INSUFFICIENT_SPACE_ON_RESOURCE}
463-
*/
464-
@Deprecated
465-
public ResultMatcher isInsufficientSpaceOnResource() {
466-
return matcher(HttpStatus.INSUFFICIENT_SPACE_ON_RESOURCE);
467-
}
468-
469-
/**
470-
* Assert the response status code is {@code HttpStatus.METHOD_FAILURE} (420).
471-
* @deprecated matching the deprecation of {@code HttpStatus.METHOD_FAILURE}
472-
*/
473-
@Deprecated
474-
public ResultMatcher isMethodFailure() {
475-
return matcher(HttpStatus.METHOD_FAILURE);
476-
}
477-
478-
/**
479-
* Assert the response status code is {@code HttpStatus.DESTINATION_LOCKED} (421).
480-
* @deprecated matching the deprecation of {@code HttpStatus.DESTINATION_LOCKED}
481-
*/
482-
@Deprecated
483-
public ResultMatcher isDestinationLocked() {
484-
return matcher(HttpStatus.DESTINATION_LOCKED);
485-
}
486-
487421
/**
488422
* Assert the response status code is {@code HttpStatus.UNPROCESSABLE_ENTITY} (422).
489423
*/

spring-web/src/main/java/org/springframework/http/HttpStatus.java

-61
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,6 @@ public enum HttpStatus implements HttpStatusCode {
127127
* @see <a href="https://tools.ietf.org/html/rfc7231#section-6.4.3">HTTP/1.1: Semantics and Content, section 6.4.3</a>
128128
*/
129129
FOUND(302, Series.REDIRECTION, "Found"),
130-
/**
131-
* {@code 302 Moved Temporarily}.
132-
* @see <a href="https://tools.ietf.org/html/rfc1945#section-9.3">HTTP/1.0, section 9.3</a>
133-
* @deprecated in favor of {@link #FOUND} which will be returned from {@code HttpStatus.valueOf(302)}
134-
*/
135-
@Deprecated
136-
MOVED_TEMPORARILY(302, Series.REDIRECTION, "Moved Temporarily"),
137130
/**
138131
* {@code 303 See Other}.
139132
* @see <a href="https://tools.ietf.org/html/rfc7231#section-6.4.4">HTTP/1.1: Semantics and Content, section 6.4.4</a>
@@ -144,13 +137,6 @@ public enum HttpStatus implements HttpStatusCode {
144137
* @see <a href="https://tools.ietf.org/html/rfc7232#section-4.1">HTTP/1.1: Conditional Requests, section 4.1</a>
145138
*/
146139
NOT_MODIFIED(304, Series.REDIRECTION, "Not Modified"),
147-
/**
148-
* {@code 305 Use Proxy}.
149-
* @see <a href="https://tools.ietf.org/html/rfc7231#section-6.4.5">HTTP/1.1: Semantics and Content, section 6.4.5</a>
150-
* @deprecated due to security concerns regarding in-band configuration of a proxy
151-
*/
152-
@Deprecated
153-
USE_PROXY(305, Series.REDIRECTION, "Use Proxy"),
154140
/**
155141
* {@code 307 Temporary Redirect}.
156142
* @see <a href="https://tools.ietf.org/html/rfc7231#section-6.4.7">HTTP/1.1: Semantics and Content, section 6.4.7</a>
@@ -239,28 +225,13 @@ public enum HttpStatus implements HttpStatusCode {
239225
* HTTP/1.1: Semantics and Content, section 6.5.11</a>
240226
*/
241227
PAYLOAD_TOO_LARGE(413, Series.CLIENT_ERROR, "Payload Too Large"),
242-
/**
243-
* {@code 413 Request Entity Too Large}.
244-
* @see <a href="https://tools.ietf.org/html/rfc2616#section-10.4.14">HTTP/1.1, section 10.4.14</a>
245-
* @deprecated in favor of {@link #PAYLOAD_TOO_LARGE} which will be
246-
* returned from {@code HttpStatus.valueOf(413)}
247-
*/
248-
@Deprecated
249-
REQUEST_ENTITY_TOO_LARGE(413, Series.CLIENT_ERROR, "Request Entity Too Large"),
250228
/**
251229
* {@code 414 URI Too Long}.
252230
* @since 4.1
253231
* @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.12">
254232
* HTTP/1.1: Semantics and Content, section 6.5.12</a>
255233
*/
256234
URI_TOO_LONG(414, Series.CLIENT_ERROR, "URI Too Long"),
257-
/**
258-
* {@code 414 Request-URI Too Long}.
259-
* @see <a href="https://tools.ietf.org/html/rfc2616#section-10.4.15">HTTP/1.1, section 10.4.15</a>
260-
* @deprecated in favor of {@link #URI_TOO_LONG} which will be returned from {@code HttpStatus.valueOf(414)}
261-
*/
262-
@Deprecated
263-
REQUEST_URI_TOO_LONG(414, Series.CLIENT_ERROR, "Request-URI Too Long"),
264235
/**
265236
* {@code 415 Unsupported Media Type}.
266237
* @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.13">
@@ -283,27 +254,6 @@ public enum HttpStatus implements HttpStatusCode {
283254
* @see <a href="https://tools.ietf.org/html/rfc2324#section-2.3.2">HTCPCP/1.0</a>
284255
*/
285256
I_AM_A_TEAPOT(418, Series.CLIENT_ERROR, "I'm a teapot"),
286-
/**
287-
* @deprecated See
288-
* <a href="https://tools.ietf.org/rfcdiff?difftype=--hwdiff&amp;url2=draft-ietf-webdav-protocol-06.txt">
289-
* WebDAV Draft Changes</a>
290-
*/
291-
@Deprecated
292-
INSUFFICIENT_SPACE_ON_RESOURCE(419, Series.CLIENT_ERROR, "Insufficient Space On Resource"),
293-
/**
294-
* @deprecated See
295-
* <a href="https://tools.ietf.org/rfcdiff?difftype=--hwdiff&amp;url2=draft-ietf-webdav-protocol-06.txt">
296-
* WebDAV Draft Changes</a>
297-
*/
298-
@Deprecated
299-
METHOD_FAILURE(420, Series.CLIENT_ERROR, "Method Failure"),
300-
/**
301-
* @deprecated
302-
* See <a href="https://tools.ietf.org/rfcdiff?difftype=--hwdiff&amp;url2=draft-ietf-webdav-protocol-06.txt">
303-
* WebDAV Draft Changes</a>
304-
*/
305-
@Deprecated
306-
DESTINATION_LOCKED(421, Series.CLIENT_ERROR, "Destination Locked"),
307257
/**
308258
* {@code 422 Unprocessable Entity}.
309259
* @see <a href="https://tools.ietf.org/html/rfc4918#section-11.2">WebDAV</a>
@@ -551,17 +501,6 @@ public int value() {
551501
return this.value;
552502
}
553503

554-
/**
555-
* Return the {@code Series} enum constant for the supplied {@code HttpStatus}.
556-
* @param status a standard HTTP status enum constant
557-
* @return the {@code Series} enum constant for the supplied {@code HttpStatus}
558-
* @deprecated as of 5.3, in favor of invoking {@link HttpStatus#series()} directly
559-
*/
560-
@Deprecated
561-
public static Series valueOf(HttpStatus status) {
562-
return status.series;
563-
}
564-
565504
/**
566505
* Return the {@code Series} enum constant for the supplied status code.
567506
* @param statusCode the HTTP status code (potentially non-standard)

spring-web/src/test/java/org/springframework/http/HttpStatusTests.java

-44
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,12 @@
1717
package org.springframework.http;
1818

1919
import java.util.LinkedHashMap;
20-
import java.util.List;
2120
import java.util.Map;
22-
import java.util.Set;
23-
import java.util.stream.Collectors;
2421

2522
import org.junit.jupiter.api.BeforeEach;
2623
import org.junit.jupiter.api.Test;
27-
import org.junit.jupiter.params.ParameterizedTest;
28-
import org.junit.jupiter.params.provider.Arguments;
29-
import org.junit.jupiter.params.provider.MethodSource;
3024

3125
import static org.assertj.core.api.Assertions.assertThat;
32-
import static org.junit.jupiter.params.provider.Arguments.arguments;
3326

3427
/**
3528
* @author Arjen Poutsma
@@ -62,7 +55,6 @@ void createStatusCodes() {
6255
statusCodes.put(302, "FOUND");
6356
statusCodes.put(303, "SEE_OTHER");
6457
statusCodes.put(304, "NOT_MODIFIED");
65-
statusCodes.put(305, "USE_PROXY");
6658
statusCodes.put(307, "TEMPORARY_REDIRECT");
6759
statusCodes.put(308, "PERMANENT_REDIRECT");
6860

@@ -85,9 +77,6 @@ void createStatusCodes() {
8577
statusCodes.put(416, "REQUESTED_RANGE_NOT_SATISFIABLE");
8678
statusCodes.put(417, "EXPECTATION_FAILED");
8779
statusCodes.put(418, "I_AM_A_TEAPOT");
88-
statusCodes.put(419, "INSUFFICIENT_SPACE_ON_RESOURCE");
89-
statusCodes.put(420, "METHOD_FAILURE");
90-
statusCodes.put(421, "DESTINATION_LOCKED");
9180
statusCodes.put(422, "UNPROCESSABLE_ENTITY");
9281
statusCodes.put(423, "LOCKED");
9382
statusCodes.put(424, "FAILED_DEPENDENCY");
@@ -127,9 +116,6 @@ void fromMapToEnum() {
127116
void fromEnumToMap() {
128117
for (HttpStatus status : HttpStatus.values()) {
129118
int code = status.value();
130-
if (DEPRECATED_CODES.contains(status)) {
131-
continue;
132-
}
133119
assertThat(statusCodes).as("Map has no value for [" + code + "]").containsKey(code);
134120
assertThat(status.name()).as("Invalid name for [" + code + "]").isEqualTo(statusCodes.get(code));
135121
}
@@ -144,34 +130,4 @@ void allStatusSeriesShouldMatchExpectations() {
144130
}
145131
}
146132

147-
@ParameterizedTest(name = "[{index}] code {0}")
148-
@MethodSource("codesWithAliases")
149-
void codeWithDeprecatedAlias(int code, HttpStatus expected, HttpStatus outdated) {
150-
HttpStatus resolved = HttpStatus.valueOf(code);
151-
assertThat(resolved)
152-
.as("HttpStatus.valueOf(" + code + ")")
153-
.isSameAs(expected)
154-
.isNotEqualTo(outdated);
155-
assertThat(outdated.isSameCodeAs(resolved))
156-
.as("outdated isSameCodeAs(resolved)")
157-
.isTrue();
158-
assertThat(outdated.value())
159-
.as("outdated value()")
160-
.isEqualTo(resolved.value());
161-
}
162-
163-
private static final Set<HttpStatus> DEPRECATED_CODES = codesWithAliases()
164-
.stream()
165-
.map(args -> (HttpStatus) args.get()[2])
166-
.collect(Collectors.toUnmodifiableSet());
167-
168-
@SuppressWarnings("deprecation")
169-
static List<Arguments> codesWithAliases() {
170-
return List.of(
171-
arguments(302, HttpStatus.FOUND, HttpStatus.MOVED_TEMPORARILY),
172-
arguments(413, HttpStatus.PAYLOAD_TOO_LARGE, HttpStatus.REQUEST_ENTITY_TOO_LARGE),
173-
arguments(414, HttpStatus.URI_TOO_LONG, HttpStatus.REQUEST_URI_TOO_LONG)
174-
);
175-
}
176-
177133
}

0 commit comments

Comments
 (0)