Clarify StatusInfo#equals
- Dominant language
- Java
- Stars
- 400
- Forks
- 143
- PR merge metrics
- No merged PRs in 30d
Description
It is a known pitfall to compare Response#getStatusInfo with one of the Status-Enums as this will return unexpected results when reasonphrase differs. Happens especially with Tomcat8.5+.
See https://blog.zenika.com/2017/05/22/some-notes-about-jax-rs-http-statuses-and-tomcat/
Even if one wanted, this cannot be fixed by overriding `equals` because `Enum`-Baseclass of `Status` declares `equals` as final. Thus depending on order of comparison, it would still behave unexpectedly.
1) Please extend javadoc of `Response#getStatusInfo()` that the returned StatusType must not be compared with a `Status` because this comparison may return unequal when reasonphrase differs; Instead the statuscodes should be compared.
2) Deprecate StatusInfo#equals with the same javadoc.
```
/**
* @deprecated May return false when reasonPhrase differs. Instead compare statusCode directly.
*/
@Deprecated
@Override
abstract boolean equals(Object obj);
```
Contributor guide
Research direction
Start with the Javadoc for Response#getStatusInfo() and the StatusInfo#equals declaration. Document that comparing the returned status information with a Status enum may fail when the reason phrase differs, deprecate equals with the supplied guidance, and verify the API documentation builds successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100