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 6412c08
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ 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 +85,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,11 @@ 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 not present 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 6412c08

Please sign in to comment.