Fix serialization compiler warnings with Java 18
As of Java 18, the serial lint warning in javac has been expanded to check for class fields that are not marked as `Serializable`. See https://www.oracle.com/java/technologies/javase/18all-relnotes.html#JDK-8202056 In the Spring Framework codebase, this can happen with `Map`, `Set` or `List` attributes which are often assigned with an unmodifiable implementation variant. Such implementations are `Serializable` but cannot be used as field types. This commit ensures that the following changes are applied: * fields are marked as transient if they can't be serialized * classes are marked as `Serializable` if this was missing * `@SuppressWarnings("serial")` is applied where relevant
This commit is contained in:
@@ -420,6 +420,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
};
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
final MultiValueMap<String, String> headers;
|
||||
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ class ReadOnlyHttpHeaders extends HttpHeaders {
|
||||
private MediaType cachedContentType;
|
||||
|
||||
@Nullable
|
||||
@SuppressWarnings("serial")
|
||||
private List<MediaType> cachedAccept;
|
||||
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ public class RestClientResponseException extends RestClientException {
|
||||
private final String responseCharset;
|
||||
|
||||
@Nullable
|
||||
@SuppressWarnings("serial")
|
||||
private Function<ResolvableType, ?> bodyConvertFunction;
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class UnknownContentTypeException extends RestClientException {
|
||||
|
||||
private static final long serialVersionUID = 2759516676367274084L;
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private final Type targetType;
|
||||
|
||||
private final MediaType contentType;
|
||||
|
||||
Reference in New Issue
Block a user