You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ds...@apache.org on 2025/09/01 04:35:59 UTC

(solr) branch branch_9x updated: SOLR-17876: Http2SolrClient: followRedirects=true flaky (#3505)

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

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


The following commit(s) were added to refs/heads/branch_9x by this push:
     new f17cc4df946 SOLR-17876: Http2SolrClient: followRedirects=true flaky (#3505)
f17cc4df946 is described below

commit f17cc4df9463f5ca10bb3fdc946699c1ff61b77a
Author: David Smiley <ds...@apache.org>
AuthorDate: Mon Sep 1 00:20:46 2025 -0400

    SOLR-17876: Http2SolrClient: followRedirects=true flaky (#3505)
    
    If someone creates an Http2SolrClient with followRedirects=true, and then uses this client to create future clients (via builder.withHttpClient), then redirect processing would be disabled on the shared instance (bad).
    
    (cherry picked from commit 7301af08f90171f4e22b9fb0e019ff9163ceae28)
---
 solr/CHANGES.txt                                                     | 4 ++++
 .../src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java  | 5 +++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 9a2bc4f7170..34fabe78c86 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -52,6 +52,10 @@ Bug Fixes
 
 * SOLR-17871: Http2SolrClient wasn't honoring idle timeout configuration above 30 seconds -- a regression. (Thomas Wöckinger, David Smiley)
 
+* SOLR-17876: Http2SolrClient: followRedirects=true: if Http2SolrClient was created with followRedirects=true,
+  and then was used to create future clients (via builder.withHttpClient), then redirect processing was wrongly
+  disabled on the shared instance. (David Smiley)
+
 Dependency Upgrades
 ---------------------
 (No changes)
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 15c2d636a54..0529029f14a 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
@@ -157,11 +157,12 @@ public class Http2SolrClient extends HttpSolrClientBase {
       this.httpClient = createHttpClient(builder);
       this.closeClient = true;
     }
+    // note: do not manipulate httpClient below this point; it could be a shared instance
+
     if (builder.listenerFactory != null) {
       this.listenerFactory.addAll(builder.listenerFactory);
     }
     updateDefaultMimeTypeForParser();
-    this.httpClient.setFollowRedirects(Boolean.TRUE.equals(builder.followRedirects));
     this.idleTimeoutMillis = builder.getIdleTimeoutMillis();
 
     try {
@@ -301,7 +302,7 @@ public class Http2SolrClient extends HttpSolrClientBase {
     httpClient.setExecutor(this.executor);
     httpClient.setStrictEventOrdering(false);
     httpClient.setConnectBlocking(true);
-    httpClient.setFollowRedirects(false);
+    httpClient.setFollowRedirects(Boolean.TRUE.equals(builder.followRedirects));
     httpClient.setMaxRequestsQueuedPerDestination(
         asyncTracker.getMaxRequestsQueuedPerDestination());
     httpClient.setUserAgentField(new HttpField(HttpHeader.USER_AGENT, USER_AGENT));