Fix RestClient generic type handling

For client side use case, the context class should be null,
consistently with what is done in HttpMessageConverterExtractor.

Closes gh-31574
This commit is contained in:
Sébastien Deleuze
2023-11-09 08:44:18 +01:00
parent 55d13a0232
commit 38724a1205
2 changed files with 27 additions and 2 deletions

View File

@@ -69,6 +69,7 @@ import org.springframework.web.util.UriBuilderFactory;
* as created by the static factory methods.
*
* @author Arjen Poutsma
* @author Sebastien Deleuze
* @since 6.1
* @see RestClient#create()
* @see RestClient#create(String)
@@ -609,11 +610,11 @@ final class DefaultRestClient implements RestClient {
for (HttpMessageConverter<?> messageConverter : DefaultRestClient.this.messageConverters) {
if (messageConverter instanceof GenericHttpMessageConverter genericHttpMessageConverter) {
if (genericHttpMessageConverter.canRead(bodyType, bodyClass, contentType)) {
if (genericHttpMessageConverter.canRead(bodyType, null, contentType)) {
if (logger.isDebugEnabled()) {
logger.debug("Reading to [" + ResolvableType.forType(bodyType) + "]");
}
return (T) genericHttpMessageConverter.read(bodyType, bodyClass, this.clientResponse);
return (T) genericHttpMessageConverter.read(bodyType, null, this.clientResponse);
}
}
if (messageConverter.canRead(bodyClass, contentType)) {