Apache Solr open-source search software
SOLR-18520: Package Uninstall should work in absence of clusterprops.json (#5052)
Jalaz Kumar2f2b21be654f
diff --git a/changelog/unreleased/SOLR-18520-uninstall-bug.yml b/changelog/unreleased/SOLR-18520-uninstall-bug.ymlnew file mode 100644index 00000000000..6e66dcb25cb--- /dev/null+++ b/changelog/unreleased/SOLR-18520-uninstall-bug.yml@@ -0,0 +1,9 @@+title:+ Package Uninstall should work in absence of clusterprops.json file+type: fixed+authors:+ - name: Jalaz Kumar+ nick: jaykay12+links:+ - name: SOLR-18520+ url: https://issues.apache.org/jira/browse/SOLR-18520diff --git a/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java b/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.javaindex b8c38274f8d..e344f8ec35d 100644--- a/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java+++ b/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java@@ -42,6 +42,7 @@ import org.apache.solr.cli.CLIUtils;import org.apache.solr.cli.SolrCLI;import org.apache.solr.cli.ToolRuntime;import org.apache.solr.client.api.util.SolrVersion;+import org.apache.solr.client.solrj.RemoteSolrException;import org.apache.solr.client.solrj.SolrClient;import org.apache.solr.client.solrj.SolrRequest;import org.apache.solr.client.solrj.SolrServerException;@@ -154,7 +155,7 @@ public class PackageManager implements Closeable {del.pkg = packageName;V2Request req =- new V2Request.Builder(PackageUtils.PACKAGE_PATH)+ new V2Request.Builder("/cluster/package").forceV2(true).withMethod(SolrRequest.METHOD.POST).withPayload(Map.of("delete", del))@@ -278,18 +279,18 @@ public class PackageManager implements Closeable {Map<String, String> packageVersions = new HashMap<>();// map of package name to multiple values of pluginMeta(Map<String, String>)Map<String, Set<PluginMeta>> packagePlugins = new HashMap<>();- Object pluginsValue;+ Object pluginsValue = null;try {NamedList<Object> response =solrClient.request(new GenericV2SolrRequest(SolrRequest.METHOD.GET, PackageUtils.CLUSTERPROPS_PATH));Integer statusCode = (Integer) response._get(List.of("responseHeader", "status"), null);- if (statusCode == null || statusCode == ErrorCode.NOT_FOUND.code) {- // Cluster props doesn't exist, that means there are no cluster level plugins installed.- pluginsValue = null;- } else {+ if (statusCode != null && statusCode != ErrorCode.NOT_FOUND.code) {+ // Cluster props exists, that means there are cluster level plugins installed.pluginsValue = response.get(ContainerPluginsApi.PLUGIN);}+ } catch (RemoteSolrException ex) {+ log.debug("Unable to fetch clusterprops for package plugins", ex);} catch (SolrServerException | IOException ex) {throw new SolrException(ErrorCode.SERVER_ERROR, ex);}