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>
(cherry picked from commit 4e4589ba6f
)
This commit is contained in:
parent
f6f03172f1
commit
5aaa5faee7
@ -105,9 +105,11 @@ public class FailureDetector extends APIMBean implements FailureDetectorMBean {
|
||||
ep.setAliave(obj.getBoolean("is_alive"));
|
||||
ep.setUpdateTimestamp(obj.getJsonNumber("update_time").longValue());
|
||||
JsonArray states = obj.getJsonArray("application_state");
|
||||
for (int j = 0; j < states.size(); j++) {
|
||||
JsonObject state = states.getJsonObject(j);
|
||||
ep.addApplicationState(state.getInt("application_state"), state.getString("value"));
|
||||
if (states != null) {
|
||||
for (int j = 0; j < states.size(); j++) {
|
||||
JsonObject state = states.getJsonObject(j);
|
||||
ep.addApplicationState(state.getInt("application_state"), state.getString("value"));
|
||||
}
|
||||
}
|
||||
res.put(obj.getString("addrs"), ep);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user