Skip to content

java.lang.StringBuffer cannot be deserialized #3446

@Lolf1010

Description

@Lolf1010

Describe the bug
I recently tried to update my jackson-version from 2.10.3 to 2.13.1 and it appears that the java.lang.StringBuffer can no longer be deserialized. java.lang.StringBuilder and java.lang.String both work as expected.

Is there a reason why the support for StringBuffer was removed somewhere between the versions or is it a bug?

Version information
2.13.1

To Reproduce

ObjectMapper mapper = new ObjectMapper();
StringBuffer a = new StringBuffer("test");
String json = mapper.writeValueAsString(a);                  // is the string "test"
StringBuffer b = mapper.readValue(json, StringBuffer.class); // throws Exception
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `java.lang.StringBuffer` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('test')

Expected behavior
java.lang.String, java.lang.StringBuilder, java.lang.StringBuffer can be serialized and deserialized.

EDIT (by @cowtowncoder )

Regression affects versions 2.12.x and 2.13.0 - 2.13.2; fixed in 2.13.3, did not affect versions up to 2.11.x.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions