Skip to content

MimeType is no longer actually serializable #26127

@holmis83

Description

@holmis83

Affects: 5.2.10 and up

The org.springframework.util.MimeType class implements Serializable interface, but since the resolvedCharset field was introduced in 5.2.10, serialization with charset will fail since Charset class does not implement Serializable.

Code to reproduce:

MimeType mimeType = new MimeType("text", "plain", StandardCharsets.UTF_8);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(mimeType);

On OpenJDK 8 & 11 (Ubuntu), the above gives java.io.NotSerializableException.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions