Skip to content

Commit

Permalink
Fixed NullPointerException on bulk request (#88358)
Browse files Browse the repository at this point in the history
Java's `ArrayList.toArray()` returns provided array when collection is empty.
Here is created a one-element array which contains null element.
Thus, returned `BulkResponse` may contains a null element as `BulkItemResponse`.
  • Loading branch information
catap authored Jul 14, 2022
1 parent 7dc02c5 commit a9fc213
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/changelog/88358.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 88385
summary: Fixed NullPointerException on bulk request
area: Distributed
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private void addResponses(BulkResponse response, Predicate<BulkItemResponse> fil
private BulkResponse getAccumulatedResponse() {
BulkItemResponse[] itemResponses;
synchronized (responses) {
itemResponses = responses.toArray(new BulkItemResponse[1]);
itemResponses = responses.toArray(new BulkItemResponse[0]);
}
long stopTimestamp = System.nanoTime();
long totalLatencyMs = TimeValue.timeValueNanos(stopTimestamp - startTimestampNanos).millis();
Expand Down

0 comments on commit a9fc213

Please sign in to comment.