Skip to content

Commit

Permalink
Fixed NullPointerException on bulk request
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`.

How to achieve:
1. Sent a request to `/_bulk?filter_path=took,errors`
2. call inside `BulkProcessor.Listener` a `BulkResponse.hasFailures()`
  • Loading branch information
catap committed Jul 13, 2022
1 parent 5fb143d commit 6174e0f
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 6174e0f

Please sign in to comment.