This is an automated email from the ASF dual-hosted git repository.

houston pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 5719866a0b5 SOLR-17776: Fix over-checking of http1 flag in 
Http2SolrClient (#3400)
5719866a0b5 is described below

commit 5719866a0b5ab6bf881f30010fb01b936e6d3a19
Author: Houston Putman <[email protected]>
AuthorDate: Mon Jun 23 13:32:48 2025 -0500

    SOLR-17776: Fix over-checking of http1 flag in Http2SolrClient (#3400)
---
 .../org/apache/solr/client/solrj/impl/Http2SolrClient.java   |  7 +++----
 .../org/apache/solr/client/solrj/impl/HttpJdkSolrClient.java |  2 +-
 .../solr/client/solrj/impl/HttpSolrClientBuilderBase.java    | 12 +++++++++++-
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git 
a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java 
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
index 76ef37613da..1259bc85a7c 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
@@ -132,8 +132,7 @@ public class Http2SolrClient extends HttpSolrClientBase {
       if (builder.followRedirects != null
           || builder.connectionTimeoutMillis != null
           || builder.maxConnectionsPerHost != null
-          || builder.useHttp1_1
-              != builder.httpClient.getTransport() instanceof 
HttpClientTransportOverHTTP
+          || builder.useHttp1_1 != null
           || builder.proxyHost != null
           || builder.sslConfig != null
           || builder.cookieStore != null
@@ -273,7 +272,7 @@ public class Http2SolrClient extends HttpSolrClientBase {
 
     HttpClient httpClient;
     HttpClientTransport transport;
-    if (builder.useHttp1_1) {
+    if (builder.shouldUseHttp1_1()) {
       if (log.isDebugEnabled()) {
         log.debug("Create Http2SolrClient with HTTP/1.1 transport");
       }
@@ -335,7 +334,7 @@ public class Http2SolrClient extends HttpSolrClientBase {
       proxy = new Socks4Proxy(address, builder.proxyIsSecure);
     } else {
       final Protocol protocol;
-      if (builder.useHttp1_1) {
+      if (builder.shouldUseHttp1_1()) {
         protocol = HttpClientTransportOverHTTP.HTTP11;
       } else {
         // see HttpClientTransportOverHTTP2#newOrigin
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 3a3160da496..0bcecb2d89d 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
@@ -119,7 +119,7 @@ public class HttpJdkSolrClient extends HttpSolrClientBase {
     }
     b.executor(this.executor);
 
-    if (builder.useHttp1_1) {
+    if (builder.shouldUseHttp1_1()) {
       this.forceHttp11 = true;
       b.version(HttpClient.Version.HTTP_1_1);
     }
diff --git 
a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClientBuilderBase.java
 
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClientBuilderBase.java
index 453f296cffc..1b4f70e62f8 100644
--- 
a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClientBuilderBase.java
+++ 
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClientBuilderBase.java
@@ -38,7 +38,8 @@ public abstract class HttpSolrClientBuilderBase<
   protected Set<String> urlParamNames;
   protected Integer maxConnectionsPerHost;
   protected ExecutorService executor;
-  protected boolean useHttp1_1 = Boolean.getBoolean("solr.http1");
+  protected final boolean defaultUseHttp1_1 = Boolean.getBoolean("solr.http1");
+  protected Boolean useHttp1_1;
   protected String proxyHost;
   protected int proxyPort;
   protected boolean proxyIsSocks4;
@@ -171,6 +172,15 @@ public abstract class HttpSolrClientBuilderBase<
     return (B) this;
   }
 
+  /**
+   * Return whether the HttpSolrClient built will prefer http1.1 over http2.
+   *
+   * @return whether to prefer http1.1
+   */
+  public boolean shouldUseHttp1_1() {
+    return useHttp1_1 != null ? useHttp1_1 : defaultUseHttp1_1;
+  }
+
   /**
    * Setup a proxy
    *

Reply via email to