Declare resolvedCharset as transient (restoring serializability)
Closes gh-26127
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.http;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@@ -26,6 +27,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
import org.springframework.core.testfixture.io.SerializationTestUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
@@ -160,7 +162,7 @@ public class MediaTypeTests {
|
||||
assertThat(mediaTypes.size()).as("Invalid amount of media types").isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test // gh-23241
|
||||
@Test // gh-23241
|
||||
public void parseMediaTypesWithTrailingComma() {
|
||||
List<MediaType> mediaTypes = MediaType.parseMediaTypes("text/plain, text/html, ");
|
||||
assertThat(mediaTypes).as("No media types returned").isNotNull();
|
||||
@@ -460,4 +462,12 @@ public class MediaTypeTests {
|
||||
assertThat(new MediaType("text", "*").isConcrete()).as("text/* concrete").isFalse();
|
||||
}
|
||||
|
||||
@Test // gh-26127
|
||||
void serialize() throws Exception {
|
||||
MediaType original = new MediaType("text", "plain", StandardCharsets.UTF_8);
|
||||
MediaType deserialized = SerializationTestUtils.serializeAndDeserialize(original);
|
||||
assertThat(deserialized).isEqualTo(original);
|
||||
assertThat(original).isEqualTo(deserialized);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user