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
  • Loading branch information
poutsma committed Nov 25, 2019
1 parent a79eade commit 5f3c7ca
Showing 1 changed file with 11 additions and 3 deletions.
Expand Up @@ -122,13 +122,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 @@ -169,6 +174,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 5f3c7ca

Please sign in to comment.