Improve empty body check

Fixes gh-22265
This commit is contained in:
Rossen Stoyanchev
2019-01-25 15:48:04 -05:00
parent d0033f12d0
commit 4560dc2818
3 changed files with 22 additions and 3 deletions

View File

@@ -175,7 +175,7 @@ public class Jackson2JsonDecoderTests extends AbstractDecoderTestCase<Jackson2Js
.verifyError(DecodingException.class));
}
@Test // #22042
@Test // gh-22042
public void decodeWithNullLiteral() {
Flux<Object> result = this.decoder.decode(Flux.concat(stringBuffer("null")),
ResolvableType.forType(Pojo.class), MediaType.APPLICATION_JSON, Collections.emptyMap());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 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,6 +113,20 @@ public class HttpMessageConverterExtractorTests {
assertNull(result);
}
@Test // gh-22265
@SuppressWarnings("unchecked")
public void nullMessageBody() throws IOException {
HttpMessageConverter<String> converter = mock(HttpMessageConverter.class);
HttpHeaders responseHeaders = new HttpHeaders();
extractor = new HttpMessageConverterExtractor<>(String.class, createConverterList(converter));
given(response.getRawStatusCode()).willReturn(HttpStatus.OK.value());
given(response.getHeaders()).willReturn(responseHeaders);
given(response.getBody()).willReturn(null);
Object result = extractor.extractData(response);
assertNull(result);
}
@Test
@SuppressWarnings("unchecked")
public void normal() throws IOException {