Skip to content

Commit

Permalink
Fix NullPointerException in Jackson2SmileDecoder
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
poutsma committed Nov 25, 2019
1 parent 2179b67 commit c164759
Showing 1 changed file with 11 additions and 3 deletions.
Expand Up @@ -120,13 +120,18 @@ private Flux<TokenBuffer> endOfInput() {
private List<TokenBuffer> parseTokenBufferFlux() throws IOException {
List<TokenBuffer> result = new ArrayList<>();

while (true) {
// SPR-16151: Smile data format uses null to separate documents
boolean previousNull = false;
while (!this.parser.isClosed()) {
JsonToken token = this.parser.nextToken();
// SPR-16151: Smile data format uses null to separate documents
if (token == JsonToken.NOT_AVAILABLE ||
(token == null && (token = this.parser.nextToken()) == null)) {
token == null && previousNull) {
break;
}
else if (token == null ) { // !previousNull
previousNull = true;
continue;
}
updateDepth(token);
if (!this.tokenizeArrayElements) {
processTokenNormal(token, result);
Expand Down Expand Up @@ -167,6 +172,9 @@ private void processTokenNormal(JsonToken token, List<TokenBuffer> result) throw

private void processTokenArray(JsonToken token, List<TokenBuffer> result) throws IOException {
if (!isTopLevelArrayToken(token)) {
if (!this.parser.hasCurrentToken()) {
System.out.println("NO CURRENT TOKEN: " + token);
}
this.tokenBuffer.copyCurrentEvent(this.parser);
}

Expand Down

0 comments on commit c164759

Please sign in to comment.