Apache Solr open-source search software
SOLR-14404: update was not working
noble3642aa3d4e1a
diff --git a/solr/core/src/java/org/apache/solr/api/CustomContainerPlugins.java b/solr/core/src/java/org/apache/solr/api/CustomContainerPlugins.javaindex fe537d9e516..6536276e294 100644--- a/solr/core/src/java/org/apache/solr/api/CustomContainerPlugins.java+++ b/solr/core/src/java/org/apache/solr/api/CustomContainerPlugins.java@@ -130,27 +130,29 @@ public class CustomContainerPlugins implements ClusterPropertiesListener, MapWricontinue;}if (e.getValue() == Diff.ADDED) {+ // this plugin is totally newfor (ApiHolder holder : apiInfo.holders) {containerApiBag.register(holder, getTemplateVars(apiInfo.info));}currentPlugins.put(e.getKey(), apiInfo);} else {+ //this plugin is being updatedApiInfo old = currentPlugins.put(e.getKey(), apiInfo);- List<ApiHolder> replaced = new ArrayList<>();for (ApiHolder holder : apiInfo.holders) {- Api oldApi = containerApiBag.lookup(holder.getPath(),- holder.getMethod().toString(), null);- if (oldApi instanceof ApiHolder) {- replaced.add((ApiHolder) oldApi);- }+ //register all new pathscontainerApiBag.register(holder, getTemplateVars(apiInfo.info));}if (old != null) {- for (ApiHolder holder : old.holders) {- if (replaced.contains(holder)) continue;// this path is present in the new one as well. so it already got replaced- containerApiBag.unregister(holder.getMethod(),getActualPath(old, holder.getPath()));+ //this is an update of the plugin. But, it is possible that+ // some paths are remved in the newer version of the plugin+ for (ApiHolder oldHolder : old.holders) {+ if(apiInfo.get(oldHolder.api.getEndPoint()) == null) {+ //there was a path in the old plugin which is not present in the new one+ containerApiBag.unregister(oldHolder.getMethod(),getActualPath(old, oldHolder.getPath()));+ }}if (old instanceof Closeable) {+ //close the old instance of the plugincloseWhileHandlingException((Closeable) old);}}@@ -208,6 +210,17 @@ public class CustomContainerPlugins implements ClusterPropertiesListener, MapWriprivate Class klas;Object instance;+ ApiHolder get(EndPoint endPoint) {+ for (ApiHolder holder : holders) {+ EndPoint e = holder.api.getEndPoint();+ if(Objects.equals(endPoint.method()[0] , e.method()[0]) &&+ Objects.equals(endPoint.path()[0], e.path()[0])) {+ return holder;+ }+ }+ return null;+ }+@SuppressWarnings({"unchecked","rawtypes"})public ApiInfo(PluginMeta info, List<String> errs) {