Skip to content

Commit

Permalink
Remove comment, continue to ignore content on Force Merge
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <widdis@gmail.com>
  • Loading branch information
dbwiddis committed Apr 18, 2024
1 parent 50a25ca commit 2028570
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 21 deletions.
3 changes: 0 additions & 3 deletions server/src/main/java/org/opensearch/rest/BaseRestHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ public final void handleRequest(RestRequest request, RestChannel channel, NodeCl
throw new IllegalArgumentException(unrecognized(request, unconsumedParams, candidateParams, "parameter"));
}

// ignore whether content is consumed
// https://github.com/opensearch-project/OpenSearch/issues/13011

usageCount.increment();
// execute the action
action.accept(channel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ public String getName() {

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
if (request.hasContent()) {
throw new IllegalArgumentException("forcemerge takes arguments in query parameters, not in the request body");
}
ForceMergeRequest mergeRequest = new ForceMergeRequest(Strings.splitStringByCommaToArray(request.param("index")));
final ForceMergeRequest mergeRequest = new ForceMergeRequest(Strings.splitStringByCommaToArray(request.param("index")));
mergeRequest.indicesOptions(IndicesOptions.fromRequest(request, mergeRequest.indicesOptions()));
mergeRequest.maxNumSegments(request.paramAsInt("max_num_segments", mergeRequest.maxNumSegments()));
mergeRequest.onlyExpungeDeletes(request.paramAsBoolean("only_expunge_deletes", mergeRequest.onlyExpungeDeletes()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,6 @@ public void setUpAction() {
controller().registerHandler(new RestForceMergeAction());
}

public void testBodyRejection() throws Exception {
final RestForceMergeAction handler = new RestForceMergeAction();
String json = JsonXContent.contentBuilder().startObject().field("max_num_segments", 1).endObject().toString();
final FakeRestRequest request = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY).withContent(
new BytesArray(json),
MediaTypeRegistry.JSON
).withPath("/_forcemerge").build();
IllegalArgumentException e = expectThrows(
IllegalArgumentException.class,
() -> handler.handleRequest(request, new FakeRestChannel(request, randomBoolean(), 1), mock(NodeClient.class))
);
assertThat(e.getMessage(), equalTo("forcemerge takes arguments in query parameters, not in the request body"));
}

public void testDeprecationMessage() {
final Map<String, String> params = new HashMap<>();
params.put("only_expunge_deletes", Boolean.TRUE.toString());
Expand Down

0 comments on commit 2028570

Please sign in to comment.