Skip to content

Commit

Permalink
Change
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Brooks committed Aug 13, 2024
1 parent e63fb6b commit 770f539
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private class ChunkHandler implements BaseRestHandler.RequestBodyChunkConsumer {

private volatile RestChannel restChannel;
private final ArrayDeque<ReleasableBytesReference> unParsedChunks = new ArrayDeque<>(4);
private final ArrayList<DocWriteRequest<?>> items = new ArrayList<>(4);
private ArrayList<DocWriteRequest<?>> items = new ArrayList<>(4);

private ChunkHandler(RestRequest request) {
this.request = request;
Expand Down Expand Up @@ -177,9 +177,11 @@ public void handleChunk(RestChannel channel, ReleasableBytesReference chunk, boo
if (isLast) {
assert unParsedChunks.isEmpty();
assert channel != null;
handler.lastItems(items, data, new RestRefCountedChunkedToXContentListener<>(channel));
} else {
handler.addItems(items, data, () -> request.contentStream().next());
handler.lastItems(new ArrayList<>(items), data, new RestRefCountedChunkedToXContentListener<>(channel));
items.clear();
} else if (items.isEmpty() == false) {
handler.addItems(new ArrayList<>(items), data, () -> request.contentStream().next());
items.clear();
}
}

Expand Down

0 comments on commit 770f539

Please sign in to comment.