Make ChunkedRestResponseBody extend Releasable#99871
Merged
DaveCTurner merged 2 commits intoelastic:mainfrom Sep 25, 2023
Merged
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.
Collaborator
|
Pinging @elastic/es-distributed (Team:Distributed) |
nik9000
approved these changes
Sep 25, 2023
Member
|
It does exactly what I need. Wonderful1 |
ChrisHegarty
approved these changes
Sep 25, 2023
Contributor
ChrisHegarty
left a comment
There was a problem hiding this comment.
Thank you @DaveCTurner. LGTM.
nik9000
approved these changes
Sep 25, 2023
| assertEquals(new BytesArray(outputStream.toByteArray()), chunkedBytes); | ||
| assertFalse(isClosed.get()); | ||
| } | ||
| assertTrue(isClosed.get()); |
Member
There was a problem hiding this comment.
👍
This is almost exactly what I have in my branch.
DaveCTurner
added a commit
to DaveCTurner/elasticsearch
that referenced
this pull request
Sep 25, 2023
Follow-up to elastic#99871 to inline and remove the deprecated overrides which do not take a `Releasable` parameter.
elasticsearchmachine
pushed a commit
that referenced
this pull request
Sep 25, 2023
Follow-up to #99871 to inline and remove the deprecated overrides which do not take a `Releasable` parameter.
DaveCTurner
added a commit
to DaveCTurner/elasticsearch
that referenced
this pull request
Jan 25, 2024
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.
DaveCTurner
added a commit
that referenced
this pull request
Jan 25, 2024
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If an unchunked body implements
Releasablethen 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
instanceofcheck since we control the body type directly. This commitmakes
ChunkedRestResponseBody extend Releasableand adds support forclosing it when the response is sent.