Improve ProblemDetail equals and hashCode
Lazy computed title property should be taken into account See gh-30294
This commit is contained in:
committed by
rstoyanchev
parent
90627b4345
commit
a8f31f5b9e
@@ -42,6 +42,7 @@ import org.springframework.util.ObjectUtils;
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
* @author Yanming Zhou
|
||||
* @since 6.0
|
||||
* @see <a href="https://datatracker.ietf.org/doc/html/rfc7807">RFC 7807</a>
|
||||
* @see org.springframework.web.ErrorResponse
|
||||
@@ -239,7 +240,7 @@ public class ProblemDetail {
|
||||
return false;
|
||||
}
|
||||
return (this.type.equals(otherDetail.type) &&
|
||||
ObjectUtils.nullSafeEquals(this.title, otherDetail.title) &&
|
||||
ObjectUtils.nullSafeEquals(this.getTitle(), otherDetail.getTitle()) &&
|
||||
this.status == otherDetail.status &&
|
||||
ObjectUtils.nullSafeEquals(this.detail, otherDetail.detail) &&
|
||||
ObjectUtils.nullSafeEquals(this.instance, otherDetail.instance) &&
|
||||
@@ -249,7 +250,7 @@ public class ProblemDetail {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.type.hashCode();
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(this.title);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(this.getTitle());
|
||||
result = 31 * result + this.status;
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(this.detail);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(this.instance);
|
||||
|
||||
Reference in New Issue
Block a user