Handle direct CanncelationException on timeout in JdkClientHttpRequest#34721
Handle direct CanncelationException on timeout in JdkClientHttpRequest#34721giampa91 wants to merge 1 commit intospring-projects:mainfrom
Conversation
1b96990 to
1717ef7
Compare
rstoyanchev
left a comment
There was a problem hiding this comment.
There seems to be no purpose to moving the TimeoutHandler
spring-web/src/main/java/org/springframework/http/client/JdkClientHttpRequest.java
Show resolved
Hide resolved
| private static final class TimeoutHandler { | ||
|
|
||
| private final CompletableFuture<Void> timeoutFuture; | ||
| private boolean isTimeout=false; |
There was a problem hiding this comment.
Likewise here, this flag is never used.
There was a problem hiding this comment.
sorry my mistake, now this variable has a purpose
…essException during timeout scenarios. Handle the CancellationExceptions in order to throw an ResourceAccessException when timeout occurred Closes spring-projectsgh-33973 Signed-off-by: giampaolo <[email protected]> fix: use timeoutHandler with a flag isTimeout Closes spring-projectsgh-33973 Signed-off-by: giampaolo <[email protected]>
|
Thank you for your patience @rstoyanchev ! After a careful review, I realized I hadn’t double-checked the code thoroughly enough. I’ve now updated the implementation to better distinguish between a cancelled request and a genuine timeout by explicitly checking the timeout variable. Additionally, I’ve added tests covering both scenarios. While there might still be room for optimization, I believe this approach reflects real-world usage and edge cases. |
rstoyanchev
left a comment
There was a problem hiding this comment.
Okay the intent is more clear now.
Handle CancellationException in order to throw an HttpTimeoutException when the timeout handler caused the cancellation. See gh-34721 Signed-off-by: giampaolo <[email protected]> fix: use timeoutHandler with a flag isTimeout Closes gh-33973 Signed-off-by: giampaolo <[email protected]>
|
Fixed via 600d6c6 |
CancellationExceptions are thrown instead of the expected ResourceAccessException during timeout scenarios.
Handle the CancellationExceptions in order to throw an ResourceAccessException when timeout occurred
Closes gh-33973