Deprecate HttpStatus 103 CHECKPOINT in favor of new EARLY_HINTS (#29816)

This commit takes rfc8297 into account and introduces a newer code 103
HttpStatus value which uses `Early Hints` as the more correct reason
phrase, deprecating the outdated `CHECKPOINT` enum value for 103.

Additionally:
  - `HttpStatus.valueOf(103)` will return the new enum value
  - `HttpStatusCode#isSameCodeAs(HttpStatusCode)` is introduced to ease
  comparison of deprecated enums vs their newer counterparts (or any
  instance of a more generic `HttpStatusCode`) by comparing the integer
  `value()`
  - `HttpStatusTests` covers the new deprecation as well as the three
  previously deprecated codes, including a check with the above new
  method to ensure they have comparable integer values

Supersedes and Closes gh-27960
This commit is contained in:
Simon Baslé
2023-01-16 11:22:43 +01:00
committed by GitHub
parent 312db36849
commit 5de1460f88
5 changed files with 77 additions and 4 deletions

View File

@@ -145,8 +145,18 @@ public class StatusResultMatchers {
/**
* Assert the response status code is {@code HttpStatus.CHECKPOINT} (103).
* @see #isEarlyHints()
* @deprecated in favor of {@link #isEarlyHints()}
*/
@Deprecated(since = "6.0")
public ResultMatcher isCheckpoint() {
return isEarlyHints();
}
/**
* Assert the response status code is {@code HttpStatus.EARLY_HINTS} (103).
*/
public ResultMatcher isEarlyHints() {
return matcher(HttpStatus.valueOf(103));
}

View File

@@ -115,12 +115,21 @@ class StatusResultMatchersDsl internal constructor (private val actions: ResultA
}
/**
* @see StatusResultMatchers.isCheckpoint
* @see isEarlyHints
*/
@Deprecated("use isEarlyHints() instead", replaceWith= ReplaceWith("isEarlyHints()"))
fun isCheckpoint() {
@Suppress("DEPRECATION")
actions.andExpect(matchers.isCheckpoint())
}
/**
* @see StatusResultMatchers.isEarlyHints
*/
fun isEarlyHints() {
actions.andExpect(matchers.isEarlyHints())
}
/**
* @see StatusResultMatchers.isOk
*/