Skip to content

Conversation

@dsmiley
Copy link
Contributor

@dsmiley dsmiley commented Nov 17, 2025

Rename HttpClientBuilderFactory to SolrClientCustomizer, and property solr.httpclient.builder.factory to solr.solrj.http.customizer

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

This somewhat fits into the separation of a solrj-jetty.

Rename HttpClientBuilderFactory to SolrClientCustomizer, and property solr.httpclient.builder.factory to solr.solrj.http.customizer
case "$(echo "$SOLR_AUTH_TYPE" | awk '{print tolower($0)}')" in
basic)
SOLR_AUTHENTICATION_CLIENT_BUILDER="org.apache.solr.client.solrj.impl.PreemptiveBasicAuthClientBuilderFactory"
SOLR_AUTHENTICATION_CLIENT_BUILDER="org.apache.solr.client.solrj.impl.PreemptiveBasicAuthClientCustomizer"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps this env var should be renamed too

|solr.solrj.cloud.max.stale.retries|cloudSolrClientMaxStaleRetries|5|Sets the maximum number of retries for stale connection attempts in SolrJ cloud client.

|solr.solrj.http.cookies.enabled|!solr.http.disableCookies| false |If Http2SolrClient should support cookies.
|solr.solrj.http.customizer|solr.httpclient.builder.factory||A class loaded to customize HttpJettySolrClient upon creation.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpJettySolrClient slipped in here... hasn't been renamed from Http2SolrClient yet

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

String factoryClassName =
System.getProperty(SolrHttpConstants.SYS_PROP_HTTP_CLIENT_BUILDER_FACTORY);
private void applyClientCustomizer() {
String factoryClassName = EnvUtils.getProperty(SolrClientCustomizer.CLIENT_CUSTOMIZER_SYSPROP);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now using EnvUtils; should now work consistently with the env var pattern if someone wishes

log.debug("Using Http Builder Factory: {}", factoryClassName);
HttpClientBuilderFactory factory;
log.debug("Using {}", factoryClassName);
SolrClientCustomizer factory;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO rename to instance

* A Java system property to select the {@linkplain HttpClientBuilderFactory} used for configuring
* HTTP based SolrClients.
*/
String SYS_PROP_HTTP_CLIENT_BUILDER_FACTORY = "solr.httpclient.builder.factory";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I felt this was better organized on the class that loads it. I can change back if asked.

* @see #CLIENT_CUSTOMIZER_SYSPROP
* @lucene.experimental
*/
public interface SolrClientCustomizer {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't need to be Closeable!

*/
String CLIENT_CUSTOMIZER_SYSPROP = "solr.solrj.http.customizer";

void setup(SolrClient client);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer mandate a specific type of SolrClient

Comment on lines +71 to +74
public void setup(SolrClient client) {
if (client instanceof Http2SolrClient == false) {
return;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gerlowskija , responding to your feedback:

The code here isn't really different than the behavior today -- if you set the sys prop, it only applies to Http2SolrClient (Jetty). If we start using this mechanism at not only the Http SolrClient level but also CloudSolrClient or whatever else that may or may not apply to this customizer, then it should skip it. But I get your concern. Perhaps the property should reflect the usage... so solr.solrj.http.jetty.customizer vs solr.solrj.http.jdk.customizer (hypothetical). With this approach, the implementation should throw an exception if the type is wrong. And the implementation should reflect it as well, like putting "Jetty" into PreemptiveBasicAuthClientJettyCustomizer. LMK what you think; I'd prefer this way.

Copy link
Contributor

@epugh epugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I focused on the sys variable changes and they Lgtm.


* The deprecated SolrClient implementations based on Apache HttpClient are removed from Solrj, thus the related dependencies are no longer present.
The system property `solr.httpclient.builder.factory` now only configures SolrClients using a Jetty based HttpClient.
The system property `solr.solrj.http.customizer` (formerly `solr.httpclient.builder.factory`) now only configures SolrClients using a Jetty based HttpClient.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We haven't done in ref guide any "formerly known" language out side of the Solr properties ref guide page for all the renamed props.

@dsmiley
Copy link
Contributor Author

dsmiley commented Nov 25, 2025

@gerlowskija if you only have time to review one of my PRs... this is one where more review would be better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants