Skip to content

Commit

Permalink
Refactor preparePutOrPost in HttpJdkSolrClient (#2454)
Browse files Browse the repository at this point in the history
  • Loading branch information
andywebb1975 authored May 17, 2024
1 parent 50d3484 commit ad0a797
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ Other Changes
* SOLR-16505: Use Jetty HTTP2 for index replication and other "recovery" operations
(Sanjay Dutt, David Smiley)

* GITHUB#2454: Refactor preparePutOrPost method in HttpJdkSolrClient (Andy Webb)

================== 9.6.0 ==================
New Features
---------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,17 @@ private PreparedRequest preparePutOrPost(

InputStream is = streams.iterator().next().getStream();
bodyPublisher = HttpRequest.BodyPublishers.ofInputStream(() -> is);
} else if (queryParams != null && urlParamNames != null) {
ModifiableSolrParams requestParams = queryParams;
queryParams = calculateQueryParams(urlParamNames, requestParams);
queryParams.add(calculateQueryParams(solrRequest.getQueryParams(), requestParams));
// note the toQueryString() method adds a leading question mark which needs to be removed here
bodyPublisher =
HttpRequest.BodyPublishers.ofString(requestParams.toQueryString().substring(1));
} else {
bodyPublisher = HttpRequest.BodyPublishers.noBody();
// move any params specified in urlParamNames or solrRequest from queryParams into urlParams
ModifiableSolrParams urlParams = calculateQueryParams(urlParamNames, queryParams);
urlParams.add(calculateQueryParams(solrRequest.getQueryParams(), queryParams));

// put the remaining params in the request body
// note the toQueryString() method adds a leading question mark which needs to be removed here
bodyPublisher = HttpRequest.BodyPublishers.ofString(queryParams.toQueryString().substring(1));

// replace queryParams with the selected set
queryParams = urlParams;
}

decorateRequest(reqb, solrRequest);
Expand Down

0 comments on commit ad0a797

Please sign in to comment.