FailureDetector: check that states is not null before use
When a node is part of a cluster but is down (like in the situation where a cluster is taken down and up again but not all nodes are up). There is no application_state information for that node. This patch check that the information exists before using it to prevent null pointer exception. After this patch, a call to nodetool gossipinfo would return the available information without failing. See scylladb/scylla#3330 Signed-off-by: Amnon Heiman <amnon@scylladb.com> Message-Id: <20180329115345.29357-1-amnon@scylladb.com>
This commit is contained in:
parent
8d499401f0
commit
4e4589ba6f
@ -105,10 +105,12 @@ public class FailureDetector extends APIMBean implements FailureDetectorMBean {
|
|||||||
ep.setAliave(obj.getBoolean("is_alive"));
|
ep.setAliave(obj.getBoolean("is_alive"));
|
||||||
ep.setUpdateTimestamp(obj.getJsonNumber("update_time").longValue());
|
ep.setUpdateTimestamp(obj.getJsonNumber("update_time").longValue());
|
||||||
JsonArray states = obj.getJsonArray("application_state");
|
JsonArray states = obj.getJsonArray("application_state");
|
||||||
|
if (states != null) {
|
||||||
for (int j = 0; j < states.size(); j++) {
|
for (int j = 0; j < states.size(); j++) {
|
||||||
JsonObject state = states.getJsonObject(j);
|
JsonObject state = states.getJsonObject(j);
|
||||||
ep.addApplicationState(state.getInt("application_state"), state.getString("value"));
|
ep.addApplicationState(state.getInt("application_state"), state.getString("value"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
res.put(obj.getString("addrs"), ep);
|
res.put(obj.getString("addrs"), ep);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
Loading…
Reference in New Issue
Block a user