Skip to content

Commit 7301af0

Browse files
authored
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).
1 parent b9be573 commit 7301af0

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

solr/CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ Bug Fixes
263263

264264
* SOLR-17871: Http2SolrClient wasn't honoring idle timeout configuration above 30 seconds -- a regression. (Thomas Wöckinger, David Smiley)
265265

266+
* SOLR-17876: Http2SolrClient: followRedirects=true: if Http2SolrClient was created with followRedirects=true,
267+
and then was used to create future clients (via builder.withHttpClient), then redirect processing was wrongly
268+
disabled on the shared instance. (David Smiley)
269+
266270
Dependency Upgrades
267271
---------------------
268272
(No changes)

solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,12 @@ protected Http2SolrClient(String serverBaseUrl, Builder builder) {
152152
this.httpClient = createHttpClient(builder);
153153
this.closeClient = true;
154154
}
155+
// note: do not manipulate httpClient below this point; it could be a shared instance
156+
155157
if (builder.listenerFactory != null) {
156158
this.listenerFactory.addAll(builder.listenerFactory);
157159
}
158160
updateDefaultMimeTypeForParser();
159-
this.httpClient.setFollowRedirects(Boolean.TRUE.equals(builder.followRedirects));
160161
this.idleTimeoutMillis = builder.getIdleTimeoutMillis();
161162

162163
try {
@@ -291,7 +292,7 @@ private HttpClient createHttpClient(Builder builder) {
291292
httpClient.setExecutor(this.executor);
292293
httpClient.setStrictEventOrdering(false);
293294
httpClient.setConnectBlocking(true);
294-
httpClient.setFollowRedirects(false);
295+
httpClient.setFollowRedirects(Boolean.TRUE.equals(builder.followRedirects));
295296
httpClient.setMaxRequestsQueuedPerDestination(
296297
asyncTracker.getMaxRequestsQueuedPerDestination());
297298
httpClient.setUserAgentField(new HttpField(HttpHeader.USER_AGENT, USER_AGENT));

0 commit comments

Comments
 (0)