APIClient: Support Empty histogram

An empty histogram can return a valid response from the API but without
any buckets.
This is a valid scenario and common for counters of features that are
not supported yet.
In those cases, the APIClient should return a zero length array.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
This commit is contained in:
Amnon Heiman 2015-11-19 11:49:31 +02:00
parent 85ab591d27
commit 5362b2045d
1 changed files with 3 additions and 0 deletions

View File

@ -677,6 +677,9 @@ public class APIClient {
MultivaluedMap<String, String> queryParams) {
JsonObject obj = getJsonObj(string, queryParams);
JsonArray arr = obj.getJsonArray("buckets");
if (arr == null) {
return new long[0];
}
long res[] = new long[arr.size()];
for (int i = 0; i< arr.size(); i++) {
res[i] = arr.getJsonNumber(i).longValue();