solr icon indicating copy to clipboard operation
solr copied to clipboard

SOLR-17044: Consolidate SolrJ URL-building logic

Open gerlowskija opened this issue 9 months ago • 4 comments

https://issues.apache.org/jira/browse/SOLR-17044

Description

URL building logic in SolrJ is complex and is duplicated in several places. This leads to bugs and added maintenance effort.

Solution

This PR consolidates much of the URL-building logic used by various SolrClient implementations into a single place (ClientUtils.buildRequestUrl(...)) that can be consumed by all "http" implementations. It builds on some nicely organized logic in HttpSolrClientBase, making only a few small tweaks (e.g. converting to a 'public static' method in order to make it more broader accessible).

One substantive change worth pointing out is that with this change HttpSolrClient now obeys SolrRequest.getBasePath(..), bringing it into line with Http2SolrClient and HttpJdkSolrClient.

I'd rather getBasePath/setBasePath not exist entirely - I mostly agree with some thoughts that David Smiley summed up on SOLR-17256. But while it exists, it probably makes sense to make similar clients (e.g. all the "http" clients) as uniform as possible in obeying or ignoring it.

Tests

Existing tests continue to pass. New unit tests in ClientUtilsTest.

Checklist

Please review the following and check all that apply:

  • [x] I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • [x] I have created a Jira issue and added the issue ID to my pull request title.
  • [x] I have given Solr maintainers access to contribute to my PR branch. (optional but recommended)
  • [x] I have developed this patch against the main branch.
  • [x] I have run ./gradlew check.
  • [x] I have added tests for my changes.

gerlowskija avatar May 10 '24 17:05 gerlowskija