-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Make ChunkedRestResponseBody extend Releasable #99871
Make ChunkedRestResponseBody extend Releasable #99871
Conversation
If an unchunked body implements `Releasable` then it is released once the response is sent. We have some need for the same behaviour with chunked bodies, except that in this case there's no need for an `instanceof` check since we control the body type directly. This commit makes `ChunkedRestResponseBody extend Releasable` and adds support for closing it when the response is sent.
Pinging @elastic/es-distributed (Team:Distributed) |
It does exactly what I need. Wonderful1 |
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.
Thank you @DaveCTurner. LGTM.
} | ||
assertTrue(isClosed.get()); |
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 is almost exactly what I have in my branch.
Follow-up to elastic#99871 to inline and remove the deprecated overrides which do not take a `Releasable` parameter.
Follow-up to #99871 to inline and remove the deprecated overrides which do not take a `Releasable` parameter.
On reflection is was probably a mistake to give each `ChunkedRestResponseBody` a nontrivial lifecycle in elastic#99871. The lifecycle really belongs to the whole containing `RestResponse`. This commit moves it there.
On reflection is was probably a mistake to give each `ChunkedRestResponseBody` a nontrivial lifecycle in #99871. The lifecycle really belongs to the whole containing `RestResponse`. This commit moves it there.
If an unchunked body implements
Releasable
then it is released oncethe response is sent. We have some need for the same behaviour with
chunked bodies, except that in this case there's no need for an
instanceof
check since we control the body type directly. This commitmakes
ChunkedRestResponseBody extend Releasable
and adds support forclosing it when the response is sent.