Merge branch '6.0.x'

This commit is contained in:
Juergen Hoeller
2023-08-04 02:40:17 +02:00
56 changed files with 198 additions and 288 deletions

View File

@@ -27,8 +27,7 @@ import org.springframework.lang.Nullable;
* @author Arjen Poutsma
* @since 6.0
*/
final class DefaultHttpStatusCode
implements HttpStatusCode, Comparable<HttpStatusCode>, Serializable {
final class DefaultHttpStatusCode implements HttpStatusCode, Comparable<HttpStatusCode>, Serializable {
private static final long serialVersionUID = 7017664779360718111L;
@@ -79,21 +78,22 @@ final class DefaultHttpStatusCode
return this.value / 100;
}
@Override
public int compareTo(@NonNull HttpStatusCode o) {
return Integer.compare(this.value, o.value());
}
@Override
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof HttpStatusCode that && this.value == that.value()));
}
@Override
public int hashCode() {
return this.value;
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj) || (obj instanceof HttpStatusCode that && this.value == that.value());
}
@Override
public String toString() {
return Integer.toString(this.value);

View File

@@ -1834,21 +1834,8 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof HttpHeaders other)) {
return false;
}
return unwrap(this).equals(unwrap(other));
}
private static MultiValueMap<String, String> unwrap(HttpHeaders headers) {
while (headers.headers instanceof HttpHeaders httpHeaders) {
headers = httpHeaders;
}
return headers.headers;
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof HttpHeaders that && unwrap(this).equals(unwrap(that))));
}
@Override
@@ -1955,6 +1942,14 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
return new String(encodedBytes, charset);
}
private static MultiValueMap<String, String> unwrap(HttpHeaders headers) {
while (headers.headers instanceof HttpHeaders httpHeaders) {
headers = httpHeaders;
}
return headers.headers;
}
// Package-private: used in ResponseCookie
static String formatDate(long date) {
Instant instant = Instant.ofEpochMilli(date);

View File

@@ -157,8 +157,8 @@ public final class HttpMethod implements Comparable<HttpMethod>, Serializable {
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj) || (obj instanceof HttpMethod that && this.name.equals(that.name));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof HttpMethod that && this.name.equals(that.name)));
}
@Override

View File

@@ -74,8 +74,8 @@ final class DefaultPathContainer implements PathContainer {
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj) || (obj instanceof PathContainer that && value().equals(that.value()));
public boolean equals(@Nullable Object other) {
return (this == other) || (other instanceof PathContainer that && value().equals(that.value()));
}
@Override
@@ -281,8 +281,8 @@ final class DefaultPathContainer implements PathContainer {
}
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj) || (obj instanceof PathSegment that && value().equals(that.value()));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof PathSegment that && this.value.equals(that.value())));
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -88,9 +88,9 @@ class MultipartFileResource extends AbstractResource {
@Override
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof MultipartFileResource other &&
this.multipartFile.equals(other.multipartFile)));
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof MultipartFileResource that &&
this.multipartFile.equals(that.multipartFile)));
}
@Override