public void onFailure(Throwable e) {
failureCounter.getAndIncrement();
int index = indexCounter.getAndIncrement();
if (accumulateExceptions()) {
shardsResponses.set(index, new ShardActionResult(
new DefaultShardOperationFailedException(request.index(), shardIt.shardId().id(), e)));
}
returnIfNeeded();
}
private void returnIfNeeded() {