spring-projects / spring-projects/spring-framework
RestClient readWithMessageConverters method hiding I/O Exceptions with incorrect error message.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
The org.springframework.web.client.DefaultRestClient#readWithMessageConverters method from spring-web:7.0.8 is hiding I/O Exceptions (SocketTimeouts from connectTimeout/readTimeout) as a RestClientException with an unrelated content-type incompatibility message:
throw new RestClientException("Error while extracting response for type [" + ResolvableType.forType(bodyType) + "] and content type [" + contentType + "]", cause);
For example a SocketTimeout exception triggered by a readTimeout set in a client configured with Accept/Content-Type headers for "application/json", throws a RestClientException with the message:
"Error while extracting response for type [MyServiceResponse] and content type [application/octet-stream]"
This message is misleading, causing confusion in the actual underlying issue. Ideally if the issue is I/O related, the readWithMessageConverters method should throw a ResourceAccessException with the proper message.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at org.springframework.web.client.DefaultRestClient#readWithMessageConverters and trace how I/O failures such as connectTimeout and readTimeout are caught and wrapped. Reproduce a timeout with JSON Accept/Content-Type headers, then verify that the resulting exception identifies the I/O failure rather than reporting content-type incompatibility.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100