diff --git a/spring-web/src/main/java/org/springframework/http/MediaType.java b/spring-web/src/main/java/org/springframework/http/MediaType.java index af3c9f9f9d..012279c12e 100644 --- a/spring-web/src/main/java/org/springframework/http/MediaType.java +++ b/spring-web/src/main/java/org/springframework/http/MediaType.java @@ -370,7 +370,6 @@ public class MediaType extends MimeType implements Serializable { private static final String PARAM_QUALITY_FACTOR = "q"; - static { // Not using "valueOf' to avoid static init cost ALL = new MediaType("*", "*"); @@ -401,7 +400,6 @@ public class MediaType extends MimeType implements Serializable { TEXT_XML = new MediaType("text", "xml"); } - /** * Create a new {@code MediaType} for the given primary type. *
The {@linkplain #getSubtype() subtype} is set to "*", parameters empty.
@@ -479,6 +477,14 @@ public class MediaType extends MimeType implements Serializable {
super(type, subtype, parameters);
}
+ /**
+ * Create a new {@code MediaType} for the given {@link MimeType}.
+ * The type, subtype and parameters information is copied and {@code MediaType}-specific
+ * checks on parameters are performed.
+ * @param mimeType the MIME type
+ * @throws IllegalArgumentException if any of the parameters contain illegal characters
+ * @since 5.3.0
+ */
public MediaType(MimeType mimeType) {
super(mimeType);
this.getParameters().forEach(this::checkParameters);
@@ -653,7 +659,7 @@ public class MediaType extends MimeType implements Serializable {
*/
public static List