Skip to content

Improve support for deserializing from TokenBuffer (f.ex for content buffered for non-blocking parsing) #5111

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
sdeleuze opened this issue Apr 25, 2025 · 2 comments
Labels
3.0 Issue planned for initial 3.0 release
Milestone

Comments

@sdeleuze
Copy link

Is your feature request related to a problem? Please describe.

With Jackson 3, in order to support customer deserializers (specified with @JsonDeserialize(using = Deserializer.class)) with non-blocking parsing, Spring has to do mapper.readerFor(javaType).readValue(tokenBuffer.asParser(mapper._deserializationContext())) in its AbstractJacksonDecoder.

We introduced this using Jackson 2 via spring-projects/spring-framework#20526, but with Jackson 3 that's not ideal given the fact that ObjectMapper#_deserializationContext() is advertised as "only public to allow for testing".

With just mapper.readerFor(javaType).readValue(tokenBuffer.asParser()) we get an UnsupportedOperationException with "Operation not supported by ObjectReadContext of type tools.jackson.core.ObjectReadContext$Base".

Describe the solution you'd like

We would like that Jackson 3 offers a way to do non-blocking parsing of instance of classes with customer deserializers without having to invoke a test-related method.

Usage example

No response

Additional context

No response

@sdeleuze sdeleuze added the to-evaluate Issue that has been received but not yet evaluated label Apr 25, 2025
@cowtowncoder cowtowncoder changed the title Improve support for non-blocking parsing with custom serializers Improve support for deserializing using TokenBuffer (f.ex for non-blocking parsing) Apr 25, 2025
@cowtowncoder
Copy link
Member

Hmmh. This will require some thinking. Perhaps specialized readValue() method that takes in TokenBuffer as source and can construct parser with DeserializationContext it manages.

@cowtowncoder cowtowncoder added 3.0 Issue planned for initial 3.0 release and removed to-evaluate Issue that has been received but not yet evaluated labels Apr 26, 2025
@cowtowncoder cowtowncoder changed the title Improve support for deserializing using TokenBuffer (f.ex for non-blocking parsing) Improve support for deserializing from TokenBuffer (f.ex for content buffered for non-blocking parsing) Apr 26, 2025
@cowtowncoder cowtowncoder added this to the 3.0.0-rc4 milestone Apr 26, 2025
@cowtowncoder
Copy link
Member

@sdeleuze I hope this works: now you can use

  • ObjectMapper.readValue(tokenBuffer, type)
  • ObjectReader.readValue(tokenBuffer)

which will properly construct and pass DeserializationContext to use.

As an added bonus added

  • ObjecMapper.writeValueIntoBuffer(Object)
  • ObjecWriter.writeValueIntoBuffer(Object)

which seem like useful things even if not needed for this use case.

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

No branches or pull requests

2 participants