Add tests for null precondition check in BulkRequest
Relates #18347 Checked with @javanna
This commit is contained in:
parent
77c4970504
commit
de3e7d161f
|
@ -169,6 +169,7 @@ public class BulkRequest extends ActionRequest<BulkRequest> implements Composite
|
|||
}
|
||||
|
||||
public BulkRequest add(DeleteRequest request, @Nullable Object payload) {
|
||||
Objects.requireNonNull(request, "'request' must not be null");
|
||||
requests.add(request);
|
||||
addPayload(payload);
|
||||
sizeInBytes += REQUEST_OVERHEAD;
|
||||
|
|
|
@ -210,4 +210,11 @@ public class BulkRequestTests extends ESTestCase {
|
|||
"script or doc is missing",
|
||||
"source is missing"));
|
||||
}
|
||||
|
||||
public void testCannotAddNullRequests() throws Exception {
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
expectThrows(NullPointerException.class, () -> bulkRequest.add((IndexRequest) null));
|
||||
expectThrows(NullPointerException.class, () -> bulkRequest.add((UpdateRequest) null));
|
||||
expectThrows(NullPointerException.class, () -> bulkRequest.add((DeleteRequest) null));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue