Description
Hi Spring-Team,
After upgrading to Spring Boot 3.4.0, we have encountered an issue with RestTemplate where random CancellationExceptions are thrown instead of the expected ResourceAccessException during timeout scenarios.
Observations:
This behavior is inconsistent; sometimes a CancellationException is thrown, and other times a ResourceAccessException is thrown.
This issue did not occur in previous versions of Spring Boot.
Reproduction:
We have created a test case to demonstrate the issue: https://github.com/SimonPNorra/timeout-execption-case
Steps to Reproduce:
Run the test case included in the project and observe the exceptions thrown. You will notice either a CancellationException or a ResourceAccessException occurring randomly.
Expected Behavior:
Consistent behavior with ResourceAccessException thrown during timeout scenarios.
Actual Behavior:
Random exceptions are thrown: either CancellationException or ResourceAccessException.
Please let us know if further information is required.
Thank you.
Regards