Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
Horus1337 opened this issue Nov 7, 2024 · 4 comments
Closed
1 task done
Milestone

Comments

@Horus1337
Copy link

Search before asking

  • I searched in the issues and found nothing similar.

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

@Horus1337 Horus1337 added the to-evaluate Issue that has been received but not yet evaluated label Nov 7, 2024
@JooHyukKim
Copy link
Member

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

@pjfanning
Copy link
Member

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

@cowtowncoder cowtowncoder changed the title Wrong String.format in StdDelegatingDeserializer hides actual error Wrong String.format() in StdDelegatingDeserializer hides actual error Nov 7, 2024
cowtowncoder added a commit that referenced this issue Nov 7, 2024
@cowtowncoder cowtowncoder added 2.16 and removed to-evaluate Issue that has been received but not yet evaluated labels Nov 7, 2024
@cowtowncoder cowtowncoder added this to the 2.16.3 milestone Nov 7, 2024
@cowtowncoder
Copy link
Member

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

@Horus1337
Copy link
Author

Horus1337 commented Nov 8, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants