Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* @param <T> the data type
* @see RestTemplate
*/
public class HttpMessageConverterExtractor<T> implements ResponseExtractor<T> {
public class HttpMessageConverterExtractor<T extends @Nullable Object> implements ResponseExtractor<T> {

private final Type responseType;

Expand Down Expand Up @@ -85,10 +85,10 @@ public HttpMessageConverterExtractor(Type responseType, List<HttpMessageConverte

@Override
@SuppressWarnings({"rawtypes", "unchecked", "resource"})
public @Nullable T extractData(ClientHttpResponse response) throws IOException {
public T extractData(ClientHttpResponse response) throws IOException {
IntrospectingClientHttpResponse responseWrapper = new IntrospectingClientHttpResponse(response);
if (!responseWrapper.hasMessageBody() || responseWrapper.hasEmptyMessageBody()) {
return null;
throw new RestClientException("No response body");
}
MediaType contentType = getContentType(responseWrapper);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@
* @see RestTemplate#execute
*/
@FunctionalInterface
public interface ResponseExtractor<T> {
public interface ResponseExtractor<T extends @Nullable Object> {

/**
* Extract data from the given {@code ClientHttpResponse} and return it.
* @param response the HTTP response
* @return the extracted data
* @throws IOException in case of I/O errors
*/
@Nullable T extractData(ClientHttpResponse response) throws IOException;
T extractData(ClientHttpResponse response) throws IOException;

}