-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Fix throws only ResourceAccessException on timeout #34721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
1b96990
to
1717ef7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be no purpose to moving the TimeoutHandler
@@ -96,12 +96,13 @@ public URI getURI() { | |||
@Override | |||
protected ClientHttpResponse executeInternal(HttpHeaders headers, @Nullable Body body) throws IOException { | |||
CompletableFuture<HttpResponse<InputStream>> responseFuture = null; | |||
TimeoutHandler timeoutHandler = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be no purpose to this change that I can see. Is this intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change was to make the TimeoutHandler readable outside the try
@@ -224,6 +228,7 @@ public ByteBuffer map(byte[] b, int off, int len) { | |||
private static final class TimeoutHandler { | |||
|
|||
private final CompletableFuture<Void> timeoutFuture; | |||
private boolean isTimeout=false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise here, this flag is never used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <giampaorr@gmail.com> fix: use timeoutHandler with a flag isTimeout Closes spring-projectsgh-33973 Signed-off-by: giampaolo <giampaorr@gmail.com>
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. |
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