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 2024/02/16 20:32:30 UTC

(solr) branch main updated: solr.xml: honor plugin enable=true|false (#2260)

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

dsmiley 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 f7c5ad3efd6 solr.xml: honor plugin enable=true|false (#2260)
f7c5ad3efd6 is described below

commit f7c5ad3efd6988f4bc03cb83af0c2070d5ba82df
Author: David Smiley <ds...@salesforce.com>
AuthorDate: Fri Feb 16 15:32:24 2024 -0500

    solr.xml: honor plugin enable=true|false (#2260)
    
    minor improvement to toggle on/off plugins defined in solr.xml
---
 .../java/org/apache/solr/core/SolrXmlConfig.java   | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
index 4c15cd9b7a9..7f91d890013 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
@@ -636,17 +636,10 @@ public class SolrXmlConfig {
   }
 
   private static PluginInfo[] getBackupRepositoryPluginInfos(List<ConfigNode> cfg) {
-    if (cfg.isEmpty()) {
-      return new PluginInfo[0];
-    }
-
-    PluginInfo[] configs = new PluginInfo[cfg.size()];
-    for (int i = 0; i < cfg.size(); i++) {
-      ConfigNode c = cfg.get(i);
-      configs[i] = new PluginInfo(c, "BackupRepositoryFactory", true, true);
-    }
-
-    return configs;
+    return cfg.stream()
+        .map(c -> new PluginInfo(c, "BackupRepositoryFactory", true, true))
+        .filter(PluginInfo::isEnabled)
+        .toArray(PluginInfo[]::new);
   }
 
   private static PluginInfo[] getClusterPlugins(SolrResourceLoader loader, ConfigNode root) {
@@ -679,6 +672,7 @@ public class SolrXmlConfig {
     List<PluginInfo> plugins =
         nodes.stream()
             .map(n -> new PluginInfo(n, n.name(), true, true))
+            .filter(PluginInfo::isEnabled)
             .collect(Collectors.toList());
 
     // Cluster plugin names must be unique
@@ -781,6 +775,9 @@ public class SolrXmlConfig {
     boolean hasJmxReporter = false;
     for (ConfigNode node : metrics.getAll("reporter")) {
       PluginInfo info = getPluginInfo(node);
+      if (info == null) {
+        continue;
+      }
       String clazz = info.className;
       if (clazz != null && clazz.equals(SolrJmxReporter.class.getName())) {
         hasJmxReporter = true;
@@ -825,6 +822,7 @@ public class SolrXmlConfig {
 
   private static PluginInfo getPluginInfo(ConfigNode cfg) {
     if (cfg == null || !cfg.exists()) return null;
-    return new PluginInfo(cfg, cfg.name(), false, true);
+    final var pluginInfo = new PluginInfo(cfg, cfg.name(), false, true);
+    return pluginInfo.isEnabled() ? pluginInfo : null;
   }
 }