Skip to content

Commit 4976595

Browse files
committed
Refactor preparePutOrPost in HttpJdkSolrClient (#2454)
1 parent 474808a commit 4976595

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

solr/CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ Other Changes
5252
* SOLR-16505: Use Jetty HTTP2 for index replication and other "recovery" operations
5353
(Sanjay Dutt, David Smiley)
5454

55+
* GITHUB#2454: Refactor preparePutOrPost method in HttpJdkSolrClient (Andy Webb)
56+
5557
================== 9.6.0 ==================
5658
New Features
5759
---------------------

solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpJdkSolrClient.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,17 @@ private PreparedRequest preparePutOrPost(
320320

321321
InputStream is = streams.iterator().next().getStream();
322322
bodyPublisher = HttpRequest.BodyPublishers.ofInputStream(() -> is);
323-
} else if (queryParams != null && urlParamNames != null) {
324-
ModifiableSolrParams requestParams = queryParams;
325-
queryParams = calculateQueryParams(urlParamNames, requestParams);
326-
queryParams.add(calculateQueryParams(solrRequest.getQueryParams(), requestParams));
327-
// note the toQueryString() method adds a leading question mark which needs to be removed here
328-
bodyPublisher =
329-
HttpRequest.BodyPublishers.ofString(requestParams.toQueryString().substring(1));
330323
} else {
331-
bodyPublisher = HttpRequest.BodyPublishers.noBody();
324+
// move any params specified in urlParamNames or solrRequest from queryParams into urlParams
325+
ModifiableSolrParams urlParams = calculateQueryParams(urlParamNames, queryParams);
326+
urlParams.add(calculateQueryParams(solrRequest.getQueryParams(), queryParams));
327+
328+
// put the remaining params in the request body
329+
// note the toQueryString() method adds a leading question mark which needs to be removed here
330+
bodyPublisher = HttpRequest.BodyPublishers.ofString(queryParams.toQueryString().substring(1));
331+
332+
// replace queryParams with the selected set
333+
queryParams = urlParams;
332334
}
333335

334336
decorateRequest(reqb, solrRequest);

0 commit comments

Comments
 (0)