From 5e3d3ef02b94d51f964a79073449f01dafa6f7a8 Mon Sep 17 00:00:00 2001 From: Andy Webb Date: Sun, 5 May 2024 17:52:34 +0100 Subject: [PATCH] Switch to getQueryString - removes length change exception --- .../org/apache/solr/client/solrj/impl/HttpJdkSolrClient.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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.java index 2d66a92bd16..a628aa42a47 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 @@ -307,7 +307,9 @@ private PreparedRequest preparePutOrPost( queryParams.add(calculateQueryParams(solrRequest.getQueryParams(), requestParams)); // bP receives any remaining params from original set // with this version the params are not fully encoded - we get raw Unicode chars, curly braces etc - and the body content length changes, presumably due to re-encoding - String bodyQueryString = requestParams.toString(); + // String bodyQueryString = requestParams.toString(); + // with this version the params are fully encoded - note the toQueryString() method adds an unwanted leading question mark + String bodyQueryString = requestParams.toQueryString().substring(1); bodyPublisher = HttpRequest.BodyPublishers.ofString(bodyQueryString); // this isn't intended to be merged - but it shows the content length change noted above if (bodyQueryString.length() != bodyPublisher.contentLength()) throw new URISyntaxException("inconsistent content length", bodyQueryString + " - " + bodyQueryString.length() + " -> " + bodyPublisher.contentLength());