Skip to content
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

NullPointerException in JSON codec parsing stream encoded with Jackson Smile #24009

feutche opened this issue Nov 16, 2019 · 3 comments


Copy link

@feutche feutche commented Nov 16, 2019

Affects: 5.1.11

Using Spring 5.1.11, Spring Boot 2.1.10, Jackson 2.10.1, but it was there in previous versions as well.

There seems to be an issue in Spring Web with #20699, streaming Smile encoded data.

I'm trying to receive a stream of objects created by Spring WebFlux app as Flux<T> using Smile encoding. JSON stream works OK.

With Smile most of the time I get NullPointerException:

at com.fasterxml.jackson.databind.util.TokenBuffer.copyCurrentEvent(
at org.springframework.http.codec.json.Jackson2Tokenizer.processTokenArray(
at org.springframework.http.codec.json.Jackson2Tokenizer.parseTokenBufferFlux(
at org.springframework.http.codec.json.Jackson2Tokenizer.tokenize(

It seems that current token of parser passed to copyCurrentEvent is null.

I'm trying now to understand how exactly does it happen but decided to raise the issue anyway.

Unfortunately it's not the easiest one to debug as it goes away if you slow it down, which probably suggests that the problem manifests itself when there's no input available to process as next array element is not received yet.

@sbrannen sbrannen added the in: web label Nov 17, 2019
@sbrannen sbrannen changed the title Nullpointer exception in JSON codec parsing stream encoded with Jackson Smile NullPointerException in JSON codec parsing stream encoded with Jackson Smile Nov 17, 2019
@poutsma poutsma self-assigned this Nov 18, 2019

This comment has been minimized.

Copy link

@poutsma poutsma commented Nov 18, 2019

After some digging through the stack trace, it seems like the null pointer occurs at this line:

So it's not the token that is null, nor the JsonParser passed to copyCurrentEvent, but rather the currentToken of the parser that returns null.

Obviously we can check whether the parser has a current token with hasCurrentToken before copying the event, but I'd like to be able to check if that fixes this issue completely. So if you'd like us to spend some time investigating, please take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem.


This comment has been minimized.

Copy link

@feutche feutche commented Nov 20, 2019
Attached example reproduces the issue for me on my not that fast laptop.
If it doesn't fail for you on faster machine you might need to tighten up the timing between produced events to increase the pressure.


This comment has been minimized.

Copy link

@poutsma poutsma commented Nov 25, 2019

Thanks for the example, I am able to reproduce the issue. I will investigate further.

@poutsma poutsma added this to the 5.2.2 milestone Nov 25, 2019
@poutsma poutsma closed this in 5f3c7ca Nov 25, 2019
poutsma added a commit that referenced this issue Nov 25, 2019
Fix uncommon case in Jackson2SmileDecoder, where a null token,
incicating a document separator in streaming mode, is followed by

Closes gh-24009

(cherry picked from commit 5f3c7ca)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.