Skip to content

Commit cc57506

Browse files
committed
Add status code 425 ("Too Early") to HttpStatus enum
Closes gh-23384
1 parent 571f6ad commit cc57506

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

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

Lines changed: 12 additions & 1 deletion
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.
@@ -319,6 +319,12 @@ public enum HttpStatus {
319319
* @see <a href="https://tools.ietf.org/html/rfc4918#section-11.4">WebDAV</a>
320320
*/
321321
FAILED_DEPENDENCY(424, "Failed Dependency"),
322+
/**
323+
* {@code 425 Too Early}.
324+
* @since 5.2
325+
* @see <a href="https://tools.ietf.org/html/rfc8470">RFC 8470</a>
326+
*/
327+
TOO_EARLY(425, "Too Early"),
322328
/**
323329
* {@code 426 Upgrade Required}.
324330
* @see <a href="https://tools.ietf.org/html/rfc2817#section-6">Upgrading to TLS Within HTTP/1.1</a>
@@ -447,6 +453,7 @@ public Series series() {
447453
* Whether this status code is in the HTTP series
448454
* {@link org.springframework.http.HttpStatus.Series#INFORMATIONAL}.
449455
* This is a shortcut for checking the value of {@link #series()}.
456+
* @since 4.0
450457
* @see #series()
451458
*/
452459
public boolean is1xxInformational() {
@@ -457,6 +464,7 @@ public boolean is1xxInformational() {
457464
* Whether this status code is in the HTTP series
458465
* {@link org.springframework.http.HttpStatus.Series#SUCCESSFUL}.
459466
* This is a shortcut for checking the value of {@link #series()}.
467+
* @since 4.0
460468
* @see #series()
461469
*/
462470
public boolean is2xxSuccessful() {
@@ -467,6 +475,7 @@ public boolean is2xxSuccessful() {
467475
* Whether this status code is in the HTTP series
468476
* {@link org.springframework.http.HttpStatus.Series#REDIRECTION}.
469477
* This is a shortcut for checking the value of {@link #series()}.
478+
* @since 4.0
470479
* @see #series()
471480
*/
472481
public boolean is3xxRedirection() {
@@ -477,6 +486,7 @@ public boolean is3xxRedirection() {
477486
* Whether this status code is in the HTTP series
478487
* {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}.
479488
* This is a shortcut for checking the value of {@link #series()}.
489+
* @since 4.0
480490
* @see #series()
481491
*/
482492
public boolean is4xxClientError() {
@@ -487,6 +497,7 @@ public boolean is4xxClientError() {
487497
* Whether this status code is in the HTTP series
488498
* {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR}.
489499
* This is a shortcut for checking the value of {@link #series()}.
500+
* @since 4.0
490501
* @see #series()
491502
*/
492503
public boolean is5xxServerError() {

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@
2424

2525
import static org.assertj.core.api.Assertions.assertThat;
2626

27-
/** @author Arjen Poutsma */
27+
/**
28+
* @author Arjen Poutsma
29+
*/
2830
public class HttpStatusTests {
2931

3032
private Map<Integer, String> statusCodes = new LinkedHashMap<>();
3133

34+
3235
@Before
3336
public void createStatusCodes() {
3437
statusCodes.put(100, "CONTINUE");
@@ -81,6 +84,7 @@ public void createStatusCodes() {
8184
statusCodes.put(422, "UNPROCESSABLE_ENTITY");
8285
statusCodes.put(423, "LOCKED");
8386
statusCodes.put(424, "FAILED_DEPENDENCY");
87+
statusCodes.put(425, "TOO_EARLY");
8488
statusCodes.put(426, "UPGRADE_REQUIRED");
8589
statusCodes.put(428, "PRECONDITION_REQUIRED");
8690
statusCodes.put(429, "TOO_MANY_REQUESTS");
@@ -101,6 +105,7 @@ public void createStatusCodes() {
101105
statusCodes.put(511, "NETWORK_AUTHENTICATION_REQUIRED");
102106
}
103107

108+
104109
@Test
105110
public void fromMapToEnum() {
106111
for (Map.Entry<Integer, String> entry : statusCodes.entrySet()) {
@@ -113,7 +118,6 @@ public void fromMapToEnum() {
113118

114119
@Test
115120
public void fromEnumToMap() {
116-
117121
for (HttpStatus status : HttpStatus.values()) {
118122
int value = status.value();
119123
if (value == 302 || value == 413 || value == 414) {
@@ -123,4 +127,5 @@ public void fromEnumToMap() {
123127
assertThat(status.name()).as("Invalid name for [" + value + "]").isEqualTo(statusCodes.get(value));
124128
}
125129
}
130+
126131
}

0 commit comments

Comments
 (0)