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

Closed
eftche opened this issue Nov 16, 2019 · 3 comments
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@eftche
Copy link

eftche 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(TokenBuffer.java:1032)
at org.springframework.http.codec.json.Jackson2Tokenizer.processTokenArray(Jackson2Tokenizer.java:170)
at org.springframework.http.codec.json.Jackson2Tokenizer.parseTokenBufferFlux(Jackson2Tokenizer.java:135)
at org.springframework.http.codec.json.Jackson2Tokenizer.tokenize(Jackson2Tokenizer.java:94)

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 16, 2019
@sbrannen sbrannen added the in: web Issues in web modules (web, webmvc, webflux, websocket) 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
@poutsma
Copy link
Contributor

poutsma commented Nov 18, 2019

After some digging through the stack trace, it seems like the null pointer occurs at this line: https://github.com/FasterXML/jackson-databind/blob/master/src/main/java/com/fasterxml/jackson/databind/util/TokenBuffer.java#L1037.

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.

@poutsma poutsma added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Nov 18, 2019
@eftche
Copy link
Author

eftche commented Nov 20, 2019

test-spring-smile.zip
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.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 20, 2019
@poutsma
Copy link
Contributor

poutsma commented Nov 25, 2019

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

@poutsma poutsma added status: waiting-for-triage An issue we've not yet triaged or decided on type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Nov 25, 2019
@poutsma poutsma added this to the 5.2.2 milestone Nov 25, 2019
@poutsma poutsma added the for: backport-to-5.1.x Marks an issue as a candidate for backport to 5.1.x label Nov 25, 2019
@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-5.1.x Marks an issue as a candidate for backport to 5.1.x labels Nov 25, 2019
@rstoyanchev rstoyanchev removed the status: feedback-provided Feedback has been provided label 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
NOT_AVAILABLE.

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
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

5 participants