SPR-8572 Support Void.class as response type in RestTemplate.
This commit is contained in:
parent
6f150e4f07
commit
c472a163f1
|
|
@ -607,7 +607,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
|||
private final HttpMessageConverterExtractor<T> delegate;
|
||||
|
||||
public ResponseEntityResponseExtractor(Class<T> responseType) {
|
||||
if (responseType != null) {
|
||||
if (responseType != null && !Void.class.equals(responseType)) {
|
||||
this.delegate = new HttpMessageConverterExtractor<T>(responseType, getMessageConverters(), logger);
|
||||
} else {
|
||||
this.delegate = null;
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ public class RestTemplateIntegrationTests {
|
|||
requestHeaders.set("MyHeader", "MyValue");
|
||||
requestHeaders.setContentType(MediaType.TEXT_PLAIN);
|
||||
HttpEntity<String> requestEntity = new HttpEntity<String>(helloWorld, requestHeaders);
|
||||
HttpEntity<?> result = template.exchange(baseUrl + "/{method}", HttpMethod.POST, requestEntity, null, "post");
|
||||
HttpEntity<Void> result = template.exchange(baseUrl + "/{method}", HttpMethod.POST, requestEntity, Void.class, "post");
|
||||
assertEquals("Invalid location", new URI(baseUrl + "/post/1"), result.getHeaders().getLocation());
|
||||
assertFalse(result.hasBody());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue