Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Brooks committed Sep 11, 2024
1 parent 50965e1 commit b0e95ba
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public void addItems(List<DocWriteRequest<?>> items, Releasable releasable, Runn
try (ThreadContext.StoredContext ignored = threadContext.stashContext()) {
requestContext.restore();
final ArrayList<Releasable> toRelease = new ArrayList<>(releasables);
releasables.clear();
client.bulk(bulkRequest, ActionListener.runAfter(new ActionListener<>() {

@Override
Expand All @@ -160,7 +161,6 @@ public void onFailure(Exception e) {
nextItems.run();
}));
}
releasables.clear();
} else {
nextItems.run();
}
Expand All @@ -184,6 +184,7 @@ public void lastItems(List<DocWriteRequest<?>> items, Releasable releasable, Act
try (ThreadContext.StoredContext ignored = threadContext.stashContext()) {
requestContext.restore();
final ArrayList<Releasable> toRelease = new ArrayList<>(releasables);
releasables.clear();
client.bulk(bulkRequest, ActionListener.runAfter(new ActionListener<>() {

private final boolean isFirstRequest = incrementalRequestSubmitted == false;
Expand All @@ -201,7 +202,6 @@ public void onFailure(Exception e) {
}
}, () -> toRelease.forEach(Releasable::close)));
}
releasables.clear();
} else {
errorResponse(listener);
}
Expand Down Expand Up @@ -270,6 +270,8 @@ private boolean internalAddItems(List<DocWriteRequest<?>> items, Releasable rele
return true;
} catch (EsRejectedExecutionException e) {
handleBulkFailure(incrementalRequestSubmitted == false, e);
releasables.forEach(Releasable::close);
releasables.clear();
return false;
}
}
Expand Down

0 comments on commit b0e95ba

Please sign in to comment.