From 9b35d41182f4aaaf8d56d23e5c240ba2705c3eef Mon Sep 17 00:00:00 2001 From: Jakub Narloch Date: Sun, 11 Oct 2015 09:53:49 +0200 Subject: [PATCH] Handling null in BufferingClientHttpResponseWrapper --- .../client/BufferingClientHttpResponseWrapper.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpResponseWrapper.java b/spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpResponseWrapper.java index 10f3de00794d..32f17b7c53f8 100644 --- a/spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpResponseWrapper.java +++ b/spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpResponseWrapper.java @@ -16,14 +16,14 @@ package org.springframework.http.client; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; - import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.util.StreamUtils; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + /** * Simple implementation of {@link ClientHttpResponse} that reads the response's body into memory, * thus allowing for multiple invocations of {@link #getBody()}. @@ -65,6 +65,10 @@ public HttpHeaders getHeaders() { @Override public InputStream getBody() throws IOException { + if(response.getBody() == null) { + return null; + } + if (this.body == null) { this.body = StreamUtils.copyToByteArray(this.response.getBody()); }