Skip to content

Commit

Permalink
fixing input validation in segments and delete pit request
Browse files Browse the repository at this point in the history
Signed-off-by: Bharathwaj G <[email protected]>
  • Loading branch information
bharath-techie committed Mar 13, 2023
1 parent c2388b5 commit 44955ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
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 @@ -87,7 +89,7 @@ public ActionRequestValidationException validate() {
}

public void fromXContent(XContentParser parser) throws IOException {
pitIds.clear();
Set<String> pitIds = new HashSet<>();
if (parser.nextToken() != XContentParser.Token.START_OBJECT) {
throw new IllegalArgumentException("Malformed content, must start with an object");
} else {
Expand Down Expand Up @@ -117,5 +119,7 @@ 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 @@ -21,7 +21,9 @@
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 @@ -91,7 +93,7 @@ public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params par
}

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

}

0 comments on commit 44955ce

Please sign in to comment.