Skip to content

Commit

Permalink
addressing review comment
Browse files Browse the repository at this point in the history
Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
  • Loading branch information
bharath-techie committed Aug 31, 2022
1 parent 1c714c7 commit 905bce2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ public GetAllPitNodesResponse(
);
}

/**
* Copy constructor that explicitly sets the list pit infos
*/
public GetAllPitNodesResponse(
List<ListPitInfo> listPitInfos,
GetAllPitNodesResponse response
) {
super(response.getClusterName(), response.getNodes(), response.failures());
pitInfos.addAll(listPitInfos);
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
Expand All @@ -77,9 +88,4 @@ public void writeNodesTo(StreamOutput out, List<GetAllPitNodeResponse> nodes) th
public List<ListPitInfo> getPitInfos() {
return Collections.unmodifiableList(new ArrayList<>(pitInfos));
}

public void clearAndSetPitInfos(List<ListPitInfo> listPitInfos) {
pitInfos.clear();
pitInfos.addAll(listPitInfos);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ public TransportDeletePitAction(
@Override
protected void doExecute(Task task, DeletePitRequest request, ActionListener<DeletePitResponse> listener) {
List<String> pitIds = request.getPitIds();
if (pitIds.size() == 1 && "_all".equals(pitIds.get(0))) {
// when security plugin intercepts the request, if PITs are empty in the cluster the PIT IDs in request will be empty
// and in this case return empty response
if(pitIds.isEmpty()) {
listener.onResponse(new DeletePitResponse(new ArrayList<>()));
}
else if (pitIds.size() == 1 && "_all".equals(pitIds.get(0))) {
deleteAllPits(listener);
} else {
deletePits(listener, request);
Expand Down

0 comments on commit 905bce2

Please sign in to comment.