From de56de9aa84a11b7b3ab0bb95fd2e24e2404a4fc Mon Sep 17 00:00:00 2001 From: "Kaihong.Wang" Date: Tue, 25 Feb 2020 01:38:40 +0800 Subject: [PATCH] fix npe in RestPluginsAction (#52620) Relates #45321 Co-authored-by: Elastic Machine --- .../rest/action/cat/RestPluginsAction.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java index dda070a27c458..9d4b4b08d625e 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java @@ -22,6 +22,7 @@ import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; +import org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules; import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.client.node.NodeClient; @@ -96,8 +97,14 @@ private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoR for (DiscoveryNode node : nodes) { NodeInfo info = nodesInfo.getNodesMap().get(node.getId()); - - for (PluginInfo pluginInfo : info.getPlugins().getPluginInfos()) { + if (info == null) { + continue; + } + PluginsAndModules plugins = info.getPlugins(); + if (plugins == null) { + continue; + } + for (PluginInfo pluginInfo : plugins.getPluginInfos()) { table.startRow(); table.addCell(node.getId()); table.addCell(node.getName());