From 84e44870ec7a89ba663f30bc76649b5a1362d9b4 Mon Sep 17 00:00:00 2001 From: Serhiy Bzhezytskyy Date: Fri, 21 Aug 2026 15:11:22 +0300 Subject: [PATCH] SOLR-18360: un-deprecate HttpJettySolrClient.addListenerFactory(HttpListenerFactory) The ticket asked to remove this instance method in favor of the Builder-only equivalent, but PKIAuthenticationPlugin (implementing HttpClientBuilderPlugin) attaches a listener to already-built clients across HttpShardHandlerFactory/UpdateShardHandler/HttpSolrClientProvider from CoreContainer.setupHttpClientForAuthPlugin -- a path that can re-fire on security.json hot-reload, on clients that other long-lived objects (e.g. HttpShardHandlerFactory's own loadbalancer) already reference. Rebuilding via the Builder instead would desync those references. Migrated the one call site that WAS just construction-time convenience (HttpShardHandlerFactory's own defaultClient) to the Builder method; left the instance method for the case it actually serves. --- .../solr/handler/component/HttpShardHandlerFactory.java | 2 +- .../solr/client/solrj/jetty/HttpJettySolrClient.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java index 8fb82603629..ea2df194d9c 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java +++ b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java @@ -309,8 +309,8 @@ public void init(PluginInfo info) { .withIdleTimeout(soTimeout, TimeUnit.MILLISECONDS) .withExecutor(commExecutor) .withMaxConnectionsPerHost(maxConnectionsPerHost) + .addListenerFactory(this.httpListenerFactory) .build(); - this.defaultClient.addListenerFactory(this.httpListenerFactory); this.loadbalancer = new LBJettySolrClient.Builder(defaultClient).build(); initReplicaListTransformers(getParameter(args, "replicaRouting", null, sb)); diff --git a/solr/solrj-jetty/src/java/org/apache/solr/client/solrj/jetty/HttpJettySolrClient.java b/solr/solrj-jetty/src/java/org/apache/solr/client/solrj/jetty/HttpJettySolrClient.java index e561dc4d056..e93b5906647 100644 --- a/solr/solrj-jetty/src/java/org/apache/solr/client/solrj/jetty/HttpJettySolrClient.java +++ b/solr/solrj-jetty/src/java/org/apache/solr/client/solrj/jetty/HttpJettySolrClient.java @@ -206,7 +206,13 @@ private void applyClientCustomizer() { } } - @Deprecated(since = "9.7") + /** + * Registers a listener factory on an already-built client, without discarding it. Prefer {@link + * Builder#addListenerFactory} when constructing a new client; this instance method exists for the + * case where the listener isn't known yet at construction time (or may need to change later), and + * this client's identity may already be relied on elsewhere, so it can't simply be rebuilt and + * swapped out. + */ public void addListenerFactory(HttpListenerFactory factory) { this.listenerFactory.add(factory); }