Skip to content

Commit

Permalink
addressing review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Bharathwaj G <[email protected]>
  • Loading branch information
G authored and bharath-techie committed May 24, 2023
1 parent aa10796 commit c5410bb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix 'org.apache.hc.core5.http.ParseException: Invalid protocol version' under JDK 16+ ([#4827](https://github.com/opensearch-project/OpenSearch/pull/4827))
- Fix compression support for h2c protocol ([#4944](https://github.com/opensearch-project/OpenSearch/pull/4944))
- Support OpenSSL Provider with default Netty allocator ([#5460](https://github.com/opensearch-project/OpenSearch/pull/5460))
- Fixing input validation in segments and delete pit request ([#6645](https://github.com/opensearch-project/OpenSearch/pull/6645))
- Replaces ZipInputStream with ZipFile to fix Zip Slip vulnerability ([#7230](https://github.com/opensearch-project/OpenSearch/pull/7230))
- Add missing validation/parsing of SearchBackpressureMode of SearchBackpressureSettings ([#7541](https://github.com/opensearch-project/OpenSearch/pull/7541))

Expand Down Expand Up @@ -137,6 +136,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add more index blocks check for resize APIs ([#6774](https://github.com/opensearch-project/OpenSearch/pull/6774))
- Replaces ZipInputStream with ZipFile to fix Zip Slip vulnerability ([#7230](https://github.com/opensearch-project/OpenSearch/pull/7230))
- Add missing validation/parsing of SearchBackpressureMode of SearchBackpressureSettings ([#7541](https://github.com/opensearch-project/OpenSearch/pull/7541))
- Fix input validation in segments and delete pit request ([#6645](https://github.com/opensearch-project/OpenSearch/pull/6645))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static org.opensearch.action.ValidateActions.addValidationError;

Expand Down Expand Up @@ -89,7 +87,7 @@ public ActionRequestValidationException validate() {
}

public void fromXContent(XContentParser parser) throws IOException {
Set<String> pitIds = new HashSet<>();
pitIds.clear();
if (parser.nextToken() != XContentParser.Token.START_OBJECT) {
throw new IllegalArgumentException("Malformed content, must start with an object");
} else {
Expand Down Expand Up @@ -119,7 +117,5 @@ public void fromXContent(XContentParser parser) throws IOException {
}
}
}
this.pitIds.clear();
this.pitIds.addAll(pitIds);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import static org.opensearch.action.search.SearchContextId.decode;
Expand Down Expand Up @@ -94,8 +96,10 @@ public TransportPitSegmentsAction(
*/
@Override
protected void doExecute(Task task, PitSegmentsRequest request, ActionListener<IndicesSegmentResponse> listener) {
List<String> pitIds = request.getPitIds();
if (pitIds.size() == 1 && "_all".equals(pitIds.get(0))) {
// remove pit id duplicates from the request
Set<String> pitIdSet = new LinkedHashSet<>(request.getPitIds());
request.clearAndSetPitIds(new ArrayList<>(pitIdSet));
if (request.getPitIds().size() == 1 && "_all".equals(request.getPitIds().get(0))) {
pitService.getAllPits(ActionListener.wrap(response -> {
request.clearAndSetPitIds(response.getPitInfos().stream().map(ListPitInfo::getPitId).collect(Collectors.toList()));
super.doExecute(task, request, listener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static org.opensearch.action.ValidateActions.addValidationError;

Expand Down Expand Up @@ -93,7 +91,7 @@ public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params par
}

public void fromXContent(XContentParser parser) throws IOException {
Set<String> pitIds = new HashSet<>();
pitIds.clear();
if (parser.nextToken() != XContentParser.Token.START_OBJECT) {
throw new IllegalArgumentException("Malformed content, must start with an object");
} else {
Expand Down Expand Up @@ -123,8 +121,6 @@ public void fromXContent(XContentParser parser) throws IOException {
}
}
}
this.pitIds.clear();
this.pitIds.addAll(pitIds);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
Expand All @@ -46,8 +48,10 @@ 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))) {
// remove pit id duplicates from the request
Set<String> pitIdSet = new LinkedHashSet<>(request.getPitIds());
request.clearAndSetPitIds(new ArrayList<>(pitIdSet));
if (request.getPitIds().size() == 1 && "_all".equals(request.getPitIds().get(0))) {
deleteAllPits(listener);
} else {
deletePits(listener, request);
Expand Down

0 comments on commit c5410bb

Please sign in to comment.