feign icon indicating copy to clipboard operation
feign copied to clipboard

Http2Client with native HttpClient does not enforce response timeout correctly

Open zkorhone opened this issue 4 months ago • 0 comments

There is a flaw in Java's interface design that makes it very easy to introduce bug where application stalls when using native HttpClient. Request timeout given applies only to point when response headers are received. Timeout does not apply to receiving body.

Official jdk issue: https://bugs.openjdk.org/browse/JDK-8208693

Easiest way to address the problem is to use async sending with orTimeout. The far more complex alternative is to create customer body handler / subscriber that is able to handle timeout correctly.

Considering that writing customer body handler is a non-trivial task and that orTimeout does address the problem, I would recommend changing feign implementation to use asyncSend. Java's internal synchronous implementation is a delegate to async call, so change to async would not change threading behaviour.

zkorhone avatar Oct 07 '25 10:10 zkorhone