Skip to content

Commit 9f48a02

Browse files
fixing input validation in segments and delete pit request
Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
1 parent c2388b5 commit 9f48a02

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6868
- Fix 'org.apache.hc.core5.http.ParseException: Invalid protocol version' under JDK 16+ ([#4827](https://github.com/opensearch-project/OpenSearch/pull/4827))
6969
- Fix compression support for h2c protocol ([#4944](https://github.com/opensearch-project/OpenSearch/pull/4944))
7070
- Support OpenSSL Provider with default Netty allocator ([#5460](https://github.com/opensearch-project/OpenSearch/pull/5460))
71-
71+
- Fixing input validation in segments and delete pit request ([#6645](https://github.com/opensearch-project/OpenSearch/pull/6645))
7272
### Security
7373

7474
## [Unreleased 2.x]

server/src/main/java/org/opensearch/action/admin/indices/segments/PitSegmentsRequest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import java.util.ArrayList;
2020
import java.util.Arrays;
2121
import java.util.Collections;
22+
import java.util.HashSet;
2223
import java.util.List;
24+
import java.util.Set;
2325

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

@@ -87,7 +89,7 @@ public ActionRequestValidationException validate() {
8789
}
8890

8991
public void fromXContent(XContentParser parser) throws IOException {
90-
pitIds.clear();
92+
Set<String> pitIds = new HashSet<>();
9193
if (parser.nextToken() != XContentParser.Token.START_OBJECT) {
9294
throw new IllegalArgumentException("Malformed content, must start with an object");
9395
} else {
@@ -117,5 +119,7 @@ public void fromXContent(XContentParser parser) throws IOException {
117119
}
118120
}
119121
}
122+
this.pitIds.clear();
123+
this.pitIds.addAll(pitIds);
120124
}
121125
}

server/src/main/java/org/opensearch/action/search/DeletePitRequest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
import java.io.IOException;
2222
import java.util.ArrayList;
2323
import java.util.Arrays;
24+
import java.util.HashSet;
2425
import java.util.List;
26+
import java.util.Set;
2527

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

@@ -91,7 +93,7 @@ public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params par
9193
}
9294

9395
public void fromXContent(XContentParser parser) throws IOException {
94-
pitIds.clear();
96+
Set<String> pitIds = new HashSet<>();
9597
if (parser.nextToken() != XContentParser.Token.START_OBJECT) {
9698
throw new IllegalArgumentException("Malformed content, must start with an object");
9799
} else {
@@ -121,6 +123,8 @@ public void fromXContent(XContentParser parser) throws IOException {
121123
}
122124
}
123125
}
126+
this.pitIds.clear();
127+
this.pitIds.addAll(pitIds);
124128
}
125129

126130
}

0 commit comments

Comments
 (0)