Jackson2JsonDecoder tolerates null literal

Fixes #22042
This commit is contained in:
Rossen Stoyanchev
2019-01-18 18:27:40 -05:00
parent 5dcde9e7d7
commit e373b46660
2 changed files with 16 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -113,7 +113,7 @@ public abstract class AbstractJackson2Decoder extends Jackson2CodecSupport imple
getObjectMapper().readerWithView(jsonView).forType(javaType) :
getObjectMapper().readerFor(javaType));
return tokens.map(tokenBuffer -> {
return tokens.flatMap(tokenBuffer -> {
try {
Object value = reader.readValue(tokenBuffer.asParser(getObjectMapper()));
if (!Hints.isLoggingSuppressed(hints)) {
@@ -122,16 +122,16 @@ public abstract class AbstractJackson2Decoder extends Jackson2CodecSupport imple
return Hints.getLogPrefix(hints) + "Decoded [" + formatted + "]";
});
}
return value;
return Mono.justOrEmpty(value);
}
catch (InvalidDefinitionException ex) {
throw new CodecException("Type definition error: " + ex.getType(), ex);
return Mono.error(new CodecException("Type definition error: " + ex.getType(), ex));
}
catch (JsonProcessingException ex) {
throw new DecodingException("JSON decoding error: " + ex.getOriginalMessage(), ex);
return Mono.error(new DecodingException("JSON decoding error: " + ex.getOriginalMessage(), ex));
}
catch (IOException ex) {
throw new DecodingException("I/O error while parsing input stream", ex);
return Mono.error(new DecodingException("I/O error while parsing input stream", ex));
}
});
}