Apache Solr open-source search software
Refactor preparePutOrPost in HttpJdkSolrClient (#2454)
Andy Webbad0a7975c286
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex bd554d527f3..1d90fa57df0 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -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---------------------diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpJdkSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpJdkSolrClient.javaindex 8fe0697878b..5a5b72e87c9 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpJdkSolrClient.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpJdkSolrClient.java@@ -298,15 +298,17 @@ public class HttpJdkSolrClient extends HttpSolrClientBase {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);