apple / servicetalk

A networking framework that evolves with your application
https://docs.servicetalk.io
Apache License 2.0
927 stars 181 forks source link

Fix response leak that can be caused by an exception during redirect #3095

Closed idelpivnitskiy closed 1 week ago

idelpivnitskiy commented 2 weeks ago

Motivation:

RedirectConfig accepts user-defined functions and it's possible that some of them can throw. RedirectSingle expects it and applies a try-catch block, but we forgot to drain the response payload body before propagating the error.

Modifications:

Result:

We do not leave undrained response payload if redirect fails with an exception.