Apache Solr open-source search software
SOLR-17994: SolrClientCustomizer (#3876)
David Smileyd7941818b495
diff --git a/changelog/unreleased/SOLR-17994-SolrClientCustomizer.yml b/changelog/unreleased/SOLR-17994-SolrClientCustomizer.ymlnew file mode 100644index 00000000000..bb3d6779a19--- /dev/null+++ b/changelog/unreleased/SOLR-17994-SolrClientCustomizer.yml@@ -0,0 +1,8 @@+# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc+title: Rename HttpClientBuilderFactory to SolrClientCustomizer, and property solr.httpclient.builder.factory to solr.solrj.http.jetty.customizer+type: other # added, changed, fixed, deprecated, removed, dependency_update, security, other+authors:+ - name: David Smiley+links:+ - name: SOLR-17994+ url: https://issues.apache.org/jira/browse/SOLR-17994diff --git a/solr/bin/solr b/solr/bin/solrindex d9a95a41efe..ec7f596144d 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -342,7 +342,7 @@ fiif [ -n "${SOLR_AUTH_TYPE:-}" ]; thencase "$(echo "$SOLR_AUTH_TYPE" | awk '{print tolower($0)}')" inbasic)- SOLR_AUTHENTICATION_CLIENT_BUILDER="org.apache.solr.client.solrj.jetty.PreemptiveBasicAuthClientBuilderFactory"+ SOLR_AUTHENTICATION_CLIENT_BUILDER="org.apache.solr.client.solrj.jetty.PreemptiveBasicAuthClientCustomizer";;*)echo "ERROR: Value specified for SOLR_AUTH_TYPE environment variable is invalid."@@ -355,7 +355,7 @@ if [ -n "${SOLR_AUTHENTICATION_CLIENT_CONFIGURER:-}" ]; thenecho " Please start using SOLR_AUTH_TYPE instead"fiif [ -n "${SOLR_AUTHENTICATION_CLIENT_BUILDER:-}" ]; then- AUTHC_CLIENT_BUILDER_ARG="-Dsolr.httpclient.builder.factory=$SOLR_AUTHENTICATION_CLIENT_BUILDER"+ AUTHC_CLIENT_BUILDER_ARG="-Dsolr.solrj.http.jetty.customizer=$SOLR_AUTHENTICATION_CLIENT_BUILDER"AUTHC_OPTS="${AUTHC_CLIENT_BUILDER_ARG:-}"fi# This looks strange, but it is to avoid extra spaces when we have only one of the values setdiff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmdindex 7396804262b..e7de0ce839d 100755--- a/solr/bin/solr.cmd+++ b/solr/bin/solr.cmd@@ -227,7 +227,7 @@ IF DEFINED SOLR_AUTH_TYPE (IF DEFINED SOLR_AUTH_TYPE (IF /I "%SOLR_AUTH_TYPE%" == "basic" (- set SOLR_AUTHENTICATION_CLIENT_BUILDER="org.apache.solr.client.solrj.jetty.PreemptiveBasicAuthClientBuilderFactory"+ set SOLR_AUTHENTICATION_CLIENT_BUILDER="org.apache.solr.client.solrj.jetty.PreemptiveBasicAuthClientCustomizer") ELSE (echo ERROR: Value specified for SOLR_AUTH_TYPE configuration variable is invalid.goto err@@ -239,7 +239,7 @@ IF DEFINED SOLR_AUTHENTICATION_CLIENT_CONFIGURER (echo Please start using SOLR_AUTH_TYPE instead)IF DEFINED SOLR_AUTHENTICATION_CLIENT_BUILDER (- set AUTHC_CLIENT_BUILDER_ARG="-Dsolr.httpclient.builder.factory=%SOLR_AUTHENTICATION_CLIENT_BUILDER%"+ set AUTHC_CLIENT_BUILDER_ARG="-Dsolr.solrj.http.jetty.customizer=%SOLR_AUTHENTICATION_CLIENT_BUILDER%")set "AUTHC_OPTS=%AUTHC_CLIENT_BUILDER_ARG% %SOLR_AUTHENTICATION_OPTS%"diff --git a/solr/bin/solr.in.cmd b/solr/bin/solr.in.cmdindex d605e04b712..81be993aa47 100755--- a/solr/bin/solr.in.cmd+++ b/solr/bin/solr.in.cmd@@ -173,7 +173,7 @@ REM set SOLR_SSL_CLIENT_TRUST_STORE_TYPE=REM Settings for authenticationREM Please configure only one of SOLR_AUTHENTICATION_CLIENT_BUILDER or SOLR_AUTH_TYPE parameters-REM set SOLR_AUTHENTICATION_CLIENT_BUILDER=org.apache.solr.client.solrj.jetty.PreemptiveBasicAuthClientBuilderFactory+REM set SOLR_AUTHENTICATION_CLIENT_BUILDER=org.apache.solr.client.solrj.jetty.PreemptiveBasicAuthClientCustomizerREM set SOLR_AUTH_TYPE=basicREM set SOLR_AUTHENTICATION_OPTS=-Dsolr.security.auth.basicauth.credentials=solr:SolrRocksdiff --git a/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTestWithAuth.java b/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTestWithAuth.javaindex e1dc4528995..3a62ac08f88 100644--- a/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTestWithAuth.java+++ b/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTestWithAuth.java@@ -27,8 +27,8 @@ import org.apache.solr.client.solrj.SolrResponse;import org.apache.solr.client.solrj.SolrServerException;import org.apache.solr.client.solrj.apache.CloudLegacySolrClient;import org.apache.solr.client.solrj.apache.HttpSolrClient;-import org.apache.solr.client.solrj.impl.SolrHttpConstants;-import org.apache.solr.client.solrj.jetty.PreemptiveBasicAuthClientBuilderFactory;+import org.apache.solr.client.solrj.jetty.HttpJettySolrClient;+import org.apache.solr.client.solrj.jetty.PreemptiveBasicAuthClientCustomizer;import org.apache.solr.client.solrj.request.CollectionAdminRequest;import org.apache.solr.client.solrj.request.QueryRequest;import org.apache.solr.client.solrj.request.SolrQuery;@@ -49,8 +49,8 @@ public class RecoveryZkTestWithAuth extends SolrCloudTestCase {// for context)if (rarely()) {System.setProperty(- SolrHttpConstants.SYS_PROP_HTTP_CLIENT_BUILDER_FACTORY,- PreemptiveBasicAuthClientBuilderFactory.class.getName());+ HttpJettySolrClient.CLIENT_CUSTOMIZER_SYSPROP,+ PreemptiveBasicAuthClientCustomizer.class.getName());System.setProperty("solr.security.auth.basicauth.credentials", SecurityJson.USER_PASS);}diff --git a/solr/solr-ref-guide/modules/configuration-guide/pages/solr-properties.adoc b/solr/solr-ref-guide/modules/configuration-guide/pages/solr-properties.adocindex a12d182b54f..1af78c0ba31 100644--- a/solr/solr-ref-guide/modules/configuration-guide/pages/solr-properties.adoc+++ b/solr/solr-ref-guide/modules/configuration-guide/pages/solr-properties.adoc@@ -102,7 +102,7 @@ NOTE: Properties marked with "!" indicate inverted meaning between pre Solr 10 a|solr.security.allow.urls|solr.allowUrls||A comma seperated list of urls for reading from.-|solr.security.allow.urls.enabled|!solr.disable.allow.urls|false|If using an allow list of accessible urls is enabled.+|solr.security.allow.urls.enabled|!solr.disable.allow.urls|false|If using an allow list of accessible urls is enabled.|solr.security.auth.plugin|authenticationPlugin||Specifies the authentication plugin to use.@@ -110,6 +110,8 @@ NOTE: Properties marked with "!" indicate inverted meaning between pre Solr 10 a|solr.solrj.http.cookies.enabled|!solr.http.disableCookies| false |If Http2SolrClient should support cookies.+|solr.solrj.http.jetty.customizer|solr.httpclient.builder.factory||A class loaded to customize HttpJettySolrClient upon creation.+|solr.streamingexpressions.facet.tiered.enabled|solr.facet.stream.tiered|true|Controls whether tiered faceting is enabled for streaming expressions.|solr.streamingexpressions.macros.enabled|StreamingExpressionMacros|false|Controls whether to expand URL parameters inside of the `expr` parameter.@@ -163,8 +165,8 @@ System properties can be set in several ways:2. In `solr.in.sh` (Unix) or `solr.in.cmd` (Windows) using environment variables3. Through environment variables (with appropriate naming conventions)-Environment variables can also be used to set these properties.-You may find this useful in environments such as Docker.+Environment variables can also be used to set these properties.+You may find this useful in environments such as Docker.Environment variables should be uppercase with dot notations equivalents, e.g. `SOLR_API_V2_ENABLED` for the property `solr.api.v2.enabled`.== See Alsodiff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/basic-authentication-plugin.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/basic-authentication-plugin.adocindex 204731a89e4..9121f0046fd 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/basic-authentication-plugin.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/basic-authentication-plugin.adoc@@ -358,9 +358,9 @@ QueryResponse rsp = req.process(client);=== Global (JVM) Basic Auth Credentials-Alternatively, users can use SolrJ's `PreemptiveBasicAuthClientBuilderFactory` to add basic authentication credentials to _all_ requests automatically.-To enable this feature, users should set the following system property `-Dsolr.httpclient.builder.factory=org.apache.solr.client.solrj.jetty.PreemptiveBasicAuthClientBuilderFactory`.-`PreemptiveBasicAuthClientBuilderFactory` allows applications to provide credentials in two different ways:+Alternatively, users can use SolrJ's `PreemptiveBasicAuthClientCustomizer` to add basic authentication credentials to _all_ requests automatically.+To enable this feature, users should set the following system property `-Dsolr.solrj.http.jetty.customizer=org.apache.solr.client.solrj.jetty.PreemptiveBasicAuthClientCustomizer`.+`PreemptiveBasicAuthClientCustomizer` allows applications to provide credentials in two different ways:. The `solr.security.auth.basicauth.credentials` system property can be passed, containing the credentials directly (e.g., `-Dsolr.security.auth.basicauth.credentials=username:password`).This option is straightforward, but may expose the credentials in the command line, depending on how they're set.diff --git a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adocindex b4fec165972..f3f7b2dc379 100644--- a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc+++ b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc@@ -78,6 +78,8 @@ The following classes were renamed with some refactorings: `Http2SolrClient` to`CloudHttp2SolrClient.Builder` has moved to `CloudSolrClient`; users should generally have no need to refer to `CloudHttp2SolrClient` or any class/member with "http2" in it.The builder will check if Jetty `HttpClient` is available and use that, otherwise fallback on a JDK based `HttpClient`.`CloudJettySolrClient` is new, proving an explicit option.+The system property `solr.solrj.http.jetty.customizer` (formerly `solr.httpclient.builder.factory`) can configure a `HttpJettySolrClient`.+The only built-in implementation is `org.apache.solr.client.solrj.jetty.PreemptiveBasicAuthClientCustomizer`, renamed from `PreemptiveBasicAuthClientCustomizer`.* `SolrClient` implementations that rely on "base URL" strings now only accept "root" URL paths (i.e. URLs that end in "/solr").Users who previously relied on collection-specific URLs to avoid including the collection name with each request can instead achieve this by specifying a "default collection" using the `withDefaultCollection` method available on most `SolrClient` Builders.@@ -90,7 +92,6 @@ Users who previously relied on collection-specific URLs to avoid including the cThis makes it clear that they pertain specifically to “JavaBin” rather than binary in general.* 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.* A number of classes moved to different packages to be better organized:ShardTerms, DelegatingClusterStateProvider, JavaBinRequestWriter, RoutedAliasTypes, SolrQuery, XMLRequestWriter, JacksonContentWriter, FastStreamingDocsCallback, InputStreamResponse, InputStreamResponseParser, JavaBinResponseParser, ResponseParser, StreamingJavaBinResponseParser, StreamingResponseCallback, XMLResponseParser, JacksonDataBindResponseParser, JsonMapResponseParser, SocketProxydiff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClientBuilderFactory.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientCustomizer.javasimilarity index 68%rename from solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClientBuilderFactory.javarename to solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientCustomizer.javaindex 48558e9b076..98dc2d57564 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClientBuilderFactory.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientCustomizer.java@@ -16,15 +16,17 @@*/package org.apache.solr.client.solrj.impl;-import java.io.Closeable;-import org.apache.solr.client.solrj.jetty.HttpJettySolrClient;+import org.apache.solr.client.solrj.SolrClient;/**- * A config hook for post-configuration of a {@linkplain HttpJettySolrClient} by its builder.+ * A config hook for post-configuration of a {@linkplain SolrClient} by its builder. It is not+ * supported by all builders.*- * @see SolrHttpConstants#SYS_PROP_HTTP_CLIENT_BUILDER_FACTORY+ * @param <T> type of SolrClient this customizer targets+ * @see org.apache.solr.client.solrj.jetty.HttpJettySolrClient#CLIENT_CUSTOMIZER_SYSPROP* @lucene.experimental*/-public interface HttpClientBuilderFactory extends Closeable {- default void setup(HttpJettySolrClient client) {}+public interface SolrClientCustomizer<T extends SolrClient> {++ void setup(T client);}diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrHttpConstants.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrHttpConstants.javaindex bc2bbaf9712..32d4fc6cbfe 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrHttpConstants.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrHttpConstants.java@@ -42,12 +42,6 @@ public interface SolrHttpConstants {/** Maximum total connections allowed */String PROP_MAX_CONNECTIONS = "maxConnections";- /**- * 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";-/*** System property consulted to determine if HTTP based SolrClients will require hostname* validation of SSL Certificates. The default behavior is to enforce peer name validation.diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/jetty/HttpJettySolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/jetty/HttpJettySolrClient.javaindex 9369f476dec..072a2add953 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/jetty/HttpJettySolrClient.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/jetty/HttpJettySolrClient.java@@ -41,10 +41,10 @@ import org.apache.solr.client.api.util.SolrVersion;import org.apache.solr.client.solrj.SolrClient;import org.apache.solr.client.solrj.SolrRequest;import org.apache.solr.client.solrj.SolrServerException;-import org.apache.solr.client.solrj.impl.HttpClientBuilderFactory;import org.apache.solr.client.solrj.impl.HttpSolrClientBase;import org.apache.solr.client.solrj.impl.HttpSolrClientBuilderBase;import org.apache.solr.client.solrj.impl.LBSolrClient;+import org.apache.solr.client.solrj.impl.SolrClientCustomizer;import org.apache.solr.client.solrj.impl.SolrHttpConstants;import org.apache.solr.client.solrj.jetty.HttpListenerFactory.RequestResponseListener;import org.apache.solr.client.solrj.request.RequestWriter;@@ -101,7 +101,15 @@ import org.slf4j.MDC;*/public class HttpJettySolrClient extends HttpSolrClientBase {// formerly known at Http2SolrClient+private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());++ /**+ * A Java system property to select the {@linkplain SolrClientCustomizer} used for configuring+ * this client.+ */+ public static final String CLIENT_CUSTOMIZER_SYSPROP = "solr.solrj.http.jetty.customizer";+public static final String REQ_PRINCIPAL_KEY = "solr-req-principal";private static final String USER_AGENT ="Solr[" + MethodHandles.lookup().lookupClass().getName() + "] " + SolrVersion.LATEST_STRING;@@ -156,7 +164,7 @@ public class HttpJettySolrClient extends HttpSolrClientBase {this.idleTimeoutMillis = builder.getIdleTimeoutMillis();try {- applyHttpClientBuilderFactory();+ applyClientCustomizer();} catch (RuntimeException e) {try {this.close();@@ -177,16 +185,16 @@ public class HttpJettySolrClient extends HttpSolrClientBase {this.authenticationStore = (AuthenticationStoreHolder) httpClient.getAuthenticationStore();}- private void applyHttpClientBuilderFactory() {- String factoryClassName =- System.getProperty(SolrHttpConstants.SYS_PROP_HTTP_CLIENT_BUILDER_FACTORY);+ @SuppressWarnings("unchecked")+ private void applyClientCustomizer() {+ String factoryClassName = EnvUtils.getProperty(CLIENT_CUSTOMIZER_SYSPROP);if (factoryClassName != null) {- log.debug("Using Http Builder Factory: {}", factoryClassName);- HttpClientBuilderFactory factory;+ log.debug("Using {}", factoryClassName);+ SolrClientCustomizer<HttpJettySolrClient> instance;try {- factory =+ instance =Class.forName(factoryClassName)- .asSubclass(HttpClientBuilderFactory.class)+ .asSubclass(SolrClientCustomizer.class).getDeclaredConstructor().newInstance();} catch (InstantiationException@@ -197,7 +205,7 @@ public class HttpJettySolrClient extends HttpSolrClientBase {throw new RuntimeException("Unable to instantiate " + HttpJettySolrClient.class.getName(), e);}- factory.setup(this);+ instance.setup(this);}}diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/jetty/PreemptiveBasicAuthClientBuilderFactory.java b/solr/solrj/src/java/org/apache/solr/client/solrj/jetty/PreemptiveBasicAuthClientCustomizer.javasimilarity index 91%rename from solr/solrj/src/java/org/apache/solr/client/solrj/jetty/PreemptiveBasicAuthClientBuilderFactory.javarename to solr/solrj/src/java/org/apache/solr/client/solrj/jetty/PreemptiveBasicAuthClientCustomizer.javaindex a7553d6cb3d..d4d0fd2bad3 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/jetty/PreemptiveBasicAuthClientBuilderFactory.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/jetty/PreemptiveBasicAuthClientCustomizer.java@@ -26,7 +26,7 @@ import java.util.HashMap;import java.util.List;import java.util.Map;import java.util.Properties;-import org.apache.solr.client.solrj.impl.HttpClientBuilderFactory;+import org.apache.solr.client.solrj.impl.SolrClientCustomizer;import org.apache.solr.client.solrj.impl.SolrHttpConstants;import org.apache.solr.common.params.MapSolrParams;import org.apache.solr.common.params.SolrParams;@@ -36,10 +36,13 @@ import org.eclipse.jetty.client.WWWAuthenticationProtocolHandler;import org.eclipse.jetty.client.internal.HttpAuthenticationStore;/**- * HttpClientConfigurer implementation providing support for preemptive Http Basic authentication- * scheme.+ * A {@link HttpJettySolrClient} {@link SolrClientCustomizer} supporting a preemptive Http Basic+ * authentication scheme.+ *+ * @see HttpJettySolrClient#CLIENT_CUSTOMIZER_SYSPROP*/-public class PreemptiveBasicAuthClientBuilderFactory implements HttpClientBuilderFactory {+public class PreemptiveBasicAuthClientCustomizer+ implements SolrClientCustomizer<HttpJettySolrClient> {/*** A system property used to specify a properties file containing default parameters used for* creating an HTTP client. This is specifically useful for configuring the HTTP basic auth@@ -66,9 +69,6 @@ public class PreemptiveBasicAuthClientBuilderFactory implements HttpClientBuildeCREDENTIAL_RESOLVER.defaultParams = params;}- @Override- public void close() throws IOException {}-@Overridepublic void setup(HttpJettySolrClient client) {final String basicAuthUser =@@ -99,10 +99,9 @@ public class PreemptiveBasicAuthClientBuilderFactory implements HttpClientBuildepublic CredentialsResolver() {String credentials =- System.getProperty(- PreemptiveBasicAuthClientBuilderFactory.SYS_PROP_BASIC_AUTH_CREDENTIALS);+ System.getProperty(PreemptiveBasicAuthClientCustomizer.SYS_PROP_BASIC_AUTH_CREDENTIALS);String configFile =- System.getProperty(PreemptiveBasicAuthClientBuilderFactory.SYS_PROP_HTTP_CLIENT_CONFIG);+ System.getProperty(PreemptiveBasicAuthClientCustomizer.SYS_PROP_HTTP_CLIENT_CONFIG);if (credentials != null && configFile != null) {throw new IllegalArgumentException(diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.javaindex e90632b02bd..632406e3278 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java@@ -39,7 +39,7 @@ import org.apache.solr.SolrJettyTestBase;import org.apache.solr.client.solrj.SolrClient;import org.apache.solr.client.solrj.SolrRequest;import org.apache.solr.client.solrj.SolrServerException;-import org.apache.solr.client.solrj.apache.HttpClientUtil;+import org.apache.solr.client.solrj.jetty.HttpJettySolrClient;import org.apache.solr.client.solrj.request.QueryRequest;import org.apache.solr.client.solrj.request.SolrQuery;import org.apache.solr.client.solrj.request.UpdateRequest;@@ -92,7 +92,7 @@ public abstract class HttpSolrClientTestBase extends SolrJettyTestBase {@Overridepublic void tearDown() throws Exception {System.clearProperty("solr.security.auth.basicauth.credentials");- System.clearProperty(HttpClientUtil.SYS_PROP_HTTP_CLIENT_BUILDER_FACTORY);+ System.clearProperty(HttpJettySolrClient.CLIENT_CUSTOMIZER_SYSPROP);DebugServlet.clear();super.tearDown();}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/jetty/PreemptiveBasicAuthClientBuilderFactoryTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/PreemptiveBasicAuthClientCustomizerTest.javasimilarity index 61%rename from solr/solrj/src/test/org/apache/solr/client/solrj/jetty/PreemptiveBasicAuthClientBuilderFactoryTest.javarename to solr/solrj/src/test/org/apache/solr/client/solrj/impl/PreemptiveBasicAuthClientCustomizerTest.javaindex 3ee8f4dcc78..ae76c810232 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/jetty/PreemptiveBasicAuthClientBuilderFactoryTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/PreemptiveBasicAuthClientCustomizerTest.java@@ -26,7 +26,7 @@ import java.util.Properties;import org.apache.solr.SolrTestCase;import org.apache.solr.client.solrj.apache.HttpClientUtil;-public class PreemptiveBasicAuthClientBuilderFactoryTest extends SolrTestCase {+public class PreemptiveBasicAuthClientCustomizerTest extends SolrTestCase {private void assertIllegalArgumentException(ThrowingRunnable executable, String expectedMessage) {Exception e = expectThrows(IllegalArgumentException.class, executable);@@ -37,43 +37,39 @@ public class PreemptiveBasicAuthClientBuilderFactoryTest extends SolrTestCase {@Overridepublic void tearDown() throws Exception {- System.clearProperty(PreemptiveBasicAuthClientBuilderFactory.SYS_PROP_BASIC_AUTH_CREDENTIALS);- System.clearProperty(PreemptiveBasicAuthClientBuilderFactory.SYS_PROP_HTTP_CLIENT_CONFIG);+ System.clearProperty(PreemptiveBasicAuthClientCustomizer.SYS_PROP_BASIC_AUTH_CREDENTIALS);+ System.clearProperty(PreemptiveBasicAuthClientCustomizer.SYS_PROP_HTTP_CLIENT_CONFIG);super.tearDown();}public void testBadSysPropsCredentials() {- System.setProperty(- PreemptiveBasicAuthClientBuilderFactory.SYS_PROP_BASIC_AUTH_CREDENTIALS, "foo");+ System.setProperty(PreemptiveBasicAuthClientCustomizer.SYS_PROP_BASIC_AUTH_CREDENTIALS, "foo");assertIllegalArgumentException(- PreemptiveBasicAuthClientBuilderFactory.CredentialsResolver::new,+ PreemptiveBasicAuthClientCustomizer.CredentialsResolver::new,"Invalid Authentication credentials");- System.setProperty(- PreemptiveBasicAuthClientBuilderFactory.SYS_PROP_BASIC_AUTH_CREDENTIALS, "foo:");+ System.setProperty(PreemptiveBasicAuthClientCustomizer.SYS_PROP_BASIC_AUTH_CREDENTIALS, "foo:");assertIllegalArgumentException(- PreemptiveBasicAuthClientBuilderFactory.CredentialsResolver::new,+ PreemptiveBasicAuthClientCustomizer.CredentialsResolver::new,"Invalid Authentication credentials");- System.setProperty(- PreemptiveBasicAuthClientBuilderFactory.SYS_PROP_BASIC_AUTH_CREDENTIALS, ":foo");+ System.setProperty(PreemptiveBasicAuthClientCustomizer.SYS_PROP_BASIC_AUTH_CREDENTIALS, ":foo");assertIllegalArgumentException(- PreemptiveBasicAuthClientBuilderFactory.CredentialsResolver::new,+ PreemptiveBasicAuthClientCustomizer.CredentialsResolver::new,"Invalid Authentication credentials");}public void testSysPropsAndPropsFile() {- System.setProperty(- PreemptiveBasicAuthClientBuilderFactory.SYS_PROP_BASIC_AUTH_CREDENTIALS, "foo");- System.setProperty(PreemptiveBasicAuthClientBuilderFactory.SYS_PROP_HTTP_CLIENT_CONFIG, "foo");+ System.setProperty(PreemptiveBasicAuthClientCustomizer.SYS_PROP_BASIC_AUTH_CREDENTIALS, "foo");+ System.setProperty(PreemptiveBasicAuthClientCustomizer.SYS_PROP_HTTP_CLIENT_CONFIG, "foo");assertIllegalArgumentException(- PreemptiveBasicAuthClientBuilderFactory.CredentialsResolver::new,+ PreemptiveBasicAuthClientCustomizer.CredentialsResolver::new,"Basic authentication credentials passed");}public void testCredentialsFromSystemProperties() {System.setProperty(- PreemptiveBasicAuthClientBuilderFactory.SYS_PROP_BASIC_AUTH_CREDENTIALS, "foo:bar");- PreemptiveBasicAuthClientBuilderFactory.CredentialsResolver credentialsResolver =- new PreemptiveBasicAuthClientBuilderFactory.CredentialsResolver();+ PreemptiveBasicAuthClientCustomizer.SYS_PROP_BASIC_AUTH_CREDENTIALS, "foo:bar");+ PreemptiveBasicAuthClientCustomizer.CredentialsResolver credentialsResolver =+ new PreemptiveBasicAuthClientCustomizer.CredentialsResolver();assertEquals("foo", credentialsResolver.defaultParams.get(HttpClientUtil.PROP_BASIC_AUTH_USER));assertEquals("bar", credentialsResolver.defaultParams.get(HttpClientUtil.PROP_BASIC_AUTH_PASS));}@@ -84,14 +80,12 @@ public class PreemptiveBasicAuthClientBuilderFactoryTest extends SolrTestCase {p.setProperty("httpBasicAuthPassword", "bar");Path f = createTempFile();try (BufferedWriter fw = Files.newBufferedWriter(f, StandardCharsets.UTF_8)) {- p.store(- fw,- "tmp properties file for PreemptiveBasicAuthClientBuilderFactoryTest.testCredentialsFromConfigFile");+ p.store(fw, "tmp properties file for " + getTestName());}System.setProperty(- PreemptiveBasicAuthClientBuilderFactory.SYS_PROP_HTTP_CLIENT_CONFIG, f.toString());- PreemptiveBasicAuthClientBuilderFactory.CredentialsResolver credentialsResolver =- new PreemptiveBasicAuthClientBuilderFactory.CredentialsResolver();+ PreemptiveBasicAuthClientCustomizer.SYS_PROP_HTTP_CLIENT_CONFIG, f.toString());+ PreemptiveBasicAuthClientCustomizer.CredentialsResolver credentialsResolver =+ new PreemptiveBasicAuthClientCustomizer.CredentialsResolver();assertEquals("foo", credentialsResolver.defaultParams.get(HttpClientUtil.PROP_BASIC_AUTH_USER));assertEquals("bar", credentialsResolver.defaultParams.get(HttpClientUtil.PROP_BASIC_AUTH_PASS));}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/jetty/HttpJettySolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/jetty/HttpJettySolrClientTest.javaindex 5606e7838c8..81c9f75bae4 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/jetty/HttpJettySolrClientTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/jetty/HttpJettySolrClientTest.java@@ -35,7 +35,6 @@ import org.apache.solr.client.solrj.SolrRequest;import org.apache.solr.client.solrj.SolrServerException;import org.apache.solr.client.solrj.impl.HttpSolrClientBuilderBase;import org.apache.solr.client.solrj.impl.HttpSolrClientTestBase;-import org.apache.solr.client.solrj.impl.SolrHttpConstants;import org.apache.solr.client.solrj.request.JavaBinRequestWriter;import org.apache.solr.client.solrj.request.QueryRequest;import org.apache.solr.client.solrj.request.SolrPing;@@ -498,13 +497,13 @@ public class HttpJettySolrClientTest extends HttpSolrClientTestBase {@Testpublic void testSetCredentialsWithSysProps() throws IOException, SolrServerException {System.setProperty(- PreemptiveBasicAuthClientBuilderFactory.SYS_PROP_BASIC_AUTH_CREDENTIALS, "foo:bar");+ PreemptiveBasicAuthClientCustomizer.SYS_PROP_BASIC_AUTH_CREDENTIALS, "foo:bar");System.setProperty(- SolrHttpConstants.SYS_PROP_HTTP_CLIENT_BUILDER_FACTORY,- PreemptiveBasicAuthClientBuilderFactory.class.getName());+ HttpJettySolrClient.CLIENT_CUSTOMIZER_SYSPROP,+ PreemptiveBasicAuthClientCustomizer.class.getName());// Hack to ensure we get a new set of parameters for this test- PreemptiveBasicAuthClientBuilderFactory.setDefaultSolrParams(- new PreemptiveBasicAuthClientBuilderFactory.CredentialsResolver().defaultParams);+ PreemptiveBasicAuthClientCustomizer.setDefaultSolrParams(+ new PreemptiveBasicAuthClientCustomizer.CredentialsResolver().defaultParams);try (var client =new HttpJettySolrClient.Builder(getBaseUrl() + DEBUG_SERVLET_PATH).withDefaultCollection(DEFAULT_CORE)@@ -527,9 +526,9 @@ public class HttpJettySolrClientTest extends HttpSolrClientTestBase {"Basic " + Base64.getEncoder().encodeToString("foo:bar".getBytes(StandardCharsets.UTF_8)),authorizationHeader);} finally {- System.clearProperty(PreemptiveBasicAuthClientBuilderFactory.SYS_PROP_BASIC_AUTH_CREDENTIALS);- System.clearProperty(SolrHttpConstants.SYS_PROP_HTTP_CLIENT_BUILDER_FACTORY);- PreemptiveBasicAuthClientBuilderFactory.setDefaultSolrParams(SolrParams.of());+ System.clearProperty(PreemptiveBasicAuthClientCustomizer.SYS_PROP_BASIC_AUTH_CREDENTIALS);+ System.clearProperty(HttpJettySolrClient.CLIENT_CUSTOMIZER_SYSPROP);+ PreemptiveBasicAuthClientCustomizer.setDefaultSolrParams(SolrParams.of());}}@@ -607,7 +606,7 @@ public class HttpJettySolrClientTest extends HttpSolrClientTestBase {@Testpublic void testBadHttpFactory() {- System.setProperty(SolrHttpConstants.SYS_PROP_HTTP_CLIENT_BUILDER_FACTORY, "FakeClassName");+ System.setProperty(HttpJettySolrClient.CLIENT_CUSTOMIZER_SYSPROP, "FakeClassName");try {SolrClient client =new HttpJettySolrClient.Builder(getBaseUrl() + DEBUG_SERVLET_PATH)