FasterXML / jackson-databind

General data-binding package for Jackson (2.x): works on streaming API (core) implementation(s)
Apache License 2.0
3.53k stars 1.38k forks source link

Wrong `String.format()` in `StdDelegatingDeserializer` hides actual error #4787

Closed Horus1337 closed 2 weeks ago

Horus1337 commented 2 weeks ago

Search before asking

Describe the bug

In com.fasterxml.jackson.databind.deser.std.StdDelegatingDeserializer

is the method

protected Object _handleIncompatibleUpdateValue(JsonParser p, DeserializationContext ctxt, Object intoValue)
        throws IOException
    {
        throw new UnsupportedOperationException(String.format
                ("Cannot update object of type %s (using deserializer for type %s)"
                        +intoValue.getClass().getName(), _delegateType));
    }

The String format in there is wrong, there is a '+' instead of ',' so another Runtime Exception is thrown.

protected Object _handleIncompatibleUpdateValue(JsonParser p, DeserializationContext ctxt, Object intoValue)
        throws IOException
    {
        throw new UnsupportedOperationException(String.format
                ("Cannot update object of type %s (using deserializer for type %s)",
                        intoValue.getClass().getName(), _delegateType));
    }

fixes this

Version Information

since 2.6.0

Reproduction

String.format ("Cannot update object of type %s (using deserializer for type %s)" +"EXAMPLE", "STRING")

Expected behavior

String.format ("Cannot update object of type %s (using deserializer for type %s)", "EXAMPLE", "STRING")

Additional context

No response

JooHyukKim commented 2 weeks ago

Please try at least 2.18 version and rewrite the issue, @Horus1337 2.6 version is ancient and no longer maintained. Thanks!

pjfanning commented 2 weeks ago

I committed 8f139afb437d3f5bab8bc35bae680cc9af59831e. I accidentally committed directly, had intended to create a branch and a PR. @cowtowncoder feel free to revert this commit.

cowtowncoder commented 2 weeks ago

@pjfanning That's fine in this case. I think I'll even backport it to 2.16/2.17/2.18.

Horus1337 commented 2 weeks ago

Thank you for the quick fix. I am using the most recent version, with the ' Version Information since 2.6.0 ' I just meant it was introduced in that version