JsonEOFException is wrapped as DecodingError

Jackson2Tokenizer now also wraps JsonProcessingException's on
endOfInput(), as it also does in tokenize(DataBuffer). This ensures
treating those errors as 400 vs 500.

Issue: SPR-16521
This commit is contained in:
Rossen Stoyanchev
2018-02-21 10:12:33 -05:00
parent a6d527e57a
commit 6959e66b25
2 changed files with 15 additions and 4 deletions

View File

@@ -27,7 +27,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.async.ByteArrayFeeder;
import com.fasterxml.jackson.databind.util.TokenBuffer;
import org.jetbrains.annotations.NotNull;
import reactor.core.publisher.Flux;
import org.springframework.core.codec.DecodingException;
@@ -114,12 +113,15 @@ class Jackson2Tokenizer {
try {
return parseTokenBufferFlux();
}
catch (JsonProcessingException ex) {
return Flux.error(new DecodingException(
"JSON decoding error: " + ex.getOriginalMessage(), ex));
}
catch (IOException ex) {
return Flux.error(ex);
}
}
@NotNull
private Flux<TokenBuffer> parseTokenBufferFlux() throws IOException {
List<TokenBuffer> result = new ArrayList<>();