parent
d0033f12d0
commit
4560dc2818
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -79,8 +79,13 @@ class MessageBodyClientHttpResponseWrapper implements ClientHttpResponse {
|
||||||
* @return {@code true} if the response has a zero-length message body, {@code false} otherwise
|
* @return {@code true} if the response has a zero-length message body, {@code false} otherwise
|
||||||
* @throws IOException in case of I/O errors
|
* @throws IOException in case of I/O errors
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
public boolean hasEmptyMessageBody() throws IOException {
|
public boolean hasEmptyMessageBody() throws IOException {
|
||||||
InputStream body = this.response.getBody();
|
InputStream body = this.response.getBody();
|
||||||
|
// Per contract body shouldn't be null, but check anyway..
|
||||||
|
if (body == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (body.markSupported()) {
|
if (body.markSupported()) {
|
||||||
body.mark(1);
|
body.mark(1);
|
||||||
if (body.read() == -1) {
|
if (body.read() == -1) {
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class Jackson2JsonDecoderTests extends AbstractDecoderTestCase<Jackson2Js
|
||||||
.verifyError(DecodingException.class));
|
.verifyError(DecodingException.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // #22042
|
@Test // gh-22042
|
||||||
public void decodeWithNullLiteral() {
|
public void decodeWithNullLiteral() {
|
||||||
Flux<Object> result = this.decoder.decode(Flux.concat(stringBuffer("null")),
|
Flux<Object> result = this.decoder.decode(Flux.concat(stringBuffer("null")),
|
||||||
ResolvableType.forType(Pojo.class), MediaType.APPLICATION_JSON, Collections.emptyMap());
|
ResolvableType.forType(Pojo.class), MediaType.APPLICATION_JSON, Collections.emptyMap());
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -113,6 +113,20 @@ public class HttpMessageConverterExtractorTests {
|
||||||
assertNull(result);
|
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
|
@Test
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void normal() throws IOException {
|
public void normal() throws IOException {
|
||||||
|
|
Loading…
Reference in New Issue