Skip to content

Commit

Permalink
Apply code review feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Lockwood <[email protected]>
  • Loading branch information
oliverlockwood committed May 28, 2024
1 parent d0420a3 commit 963f929
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
8 changes: 7 additions & 1 deletion client/rest/src/main/java/org/opensearch/client/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ public void addParameters(Map<String, String> paramSource) {
* will change it.
*/
public Map<String, String> getParameters() {
return unmodifiableMap(parameters);
if (options.getParameters().isEmpty()) {
return unmodifiableMap(parameters);
} else {
Map<String, String> combinedParameters = new HashMap<>(parameters);
combinedParameters.putAll(options.getParameters());
return unmodifiableMap(combinedParameters);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public List<Header> getHeaders() {
}

/**
* Query parameters to attach to the request.
* Query parameters to attach to the request. Any parameters present here
* will override matching parameters in the {@link Request}, if they exist.
*/
public Map<String, String> getParameters() {
return parameters;
Expand Down Expand Up @@ -250,7 +251,8 @@ public Builder addHeader(String name, String value) {
}

/**
* Add the provided query parameter to the request.
* Add the provided query parameter to the request. Any parameters added here
* will override matching parameters in the {@link Request}, if they exist.
*
* @param name the query parameter name
* @param value the query parameter value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,6 @@ private class InternalRequest {
InternalRequest(Request request) {
this.request = request;
Map<String, String> params = new HashMap<>(request.getParameters());
params.putAll(request.getOptions().getParameters());
// ignore is a special parameter supported by the clients, shouldn't be sent to es
String ignoreString = params.remove("ignore");
this.ignoreErrorCodes = getIgnoreErrorCodes(ignoreString, request.getMethod());
Expand Down

0 comments on commit 963f929

Please sign in to comment.