Support empty body in Jackson2JsonDecoder.decodeToMono
Prior to this commit, extracting an HTTP response with an empty body and no Content-Type header using the WebClient would: * trigger the use of the Jackson2JsonDecoder * throw a NoSuchElementException because of the use of `Flux.single()` This commit changes this behavior to `Flux.singleOrEmpty()` to avoid throwing exceptions for empty Flux instances. Issue: SPR-14582
This commit is contained in:
@@ -87,7 +87,7 @@ public class Jackson2JsonDecoder extends AbstractJackson2Codec implements Decode
|
||||
MimeType mimeType, Object... hints) {
|
||||
|
||||
JsonObjectDecoder objectDecoder = this.monoObjectDecoder;
|
||||
return decodeInternal(objectDecoder, inputStream, elementType, mimeType, hints).single();
|
||||
return decodeInternal(objectDecoder, inputStream, elementType, mimeType, hints).singleOrEmpty();
|
||||
}
|
||||
|
||||
private Flux<Object> decodeInternal(JsonObjectDecoder objectDecoder, Publisher<DataBuffer> inputStream,
|
||||
|
||||
Reference in New Issue
Block a user