Skip to content

Commit 963f929

Browse files
Apply code review feedback
Signed-off-by: Oliver Lockwood <oliver.lockwood@cantab.net>
1 parent d0420a3 commit 963f929

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

client/rest/src/main/java/org/opensearch/client/Request.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@ public void addParameters(Map<String, String> paramSource) {
110110
* will change it.
111111
*/
112112
public Map<String, String> getParameters() {
113-
return unmodifiableMap(parameters);
113+
if (options.getParameters().isEmpty()) {
114+
return unmodifiableMap(parameters);
115+
} else {
116+
Map<String, String> combinedParameters = new HashMap<>(parameters);
117+
combinedParameters.putAll(options.getParameters());
118+
return unmodifiableMap(combinedParameters);
119+
}
114120
}
115121

116122
/**

client/rest/src/main/java/org/opensearch/client/RequestOptions.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ public List<Header> getHeaders() {
9191
}
9292

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

252253
/**
253-
* Add the provided query parameter to the request.
254+
* Add the provided query parameter to the request. Any parameters added here
255+
* will override matching parameters in the {@link Request}, if they exist.
254256
*
255257
* @param name the query parameter name
256258
* @param value the query parameter value

client/rest/src/main/java/org/opensearch/client/RestClient.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,6 @@ private class InternalRequest {
832832
InternalRequest(Request request) {
833833
this.request = request;
834834
Map<String, String> params = new HashMap<>(request.getParameters());
835-
params.putAll(request.getOptions().getParameters());
836835
// ignore is a special parameter supported by the clients, shouldn't be sent to es
837836
String ignoreString = params.remove("ignore");
838837
this.ignoreErrorCodes = getIgnoreErrorCodes(ignoreString, request.getMethod());

0 commit comments

Comments
 (0)