linkedin / rest.li

Rest.li is a REST+JSON framework for building robust, scalable service architectures using dynamic discovery and simple asynchronous APIs.
rest.li
Other
2.51k stars 546 forks source link

Fix r2-netty illegal state exception due to premature channel recycling #973

Closed TylerHorth closed 9 months ago

TylerHorth commented 9 months ago

Currently, the r2-netty client recycles connections once the response body has been fully received. However, it is possible for a server to return a response before fully consuming the request body. In this case, the channel will be recycled before the request body has made it through the pipeline. If a subsequent request comes in before the prior request is complete, an illegal state exception is thrown by the netty http object encoder.

I created a unit test to reproduce the issue and updated the lifecycle handler to recycle the channel only after both the request and response are complete.

jcleezer commented 9 months ago

Fix looks good!

zackthehuman commented 9 months ago

Needs rebase due to the minor version being bumped. See #974.