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:
parent
85ab591d27
commit
5362b2045d
@ -677,6 +677,9 @@ public class APIClient {
|
|||||||
MultivaluedMap<String, String> queryParams) {
|
MultivaluedMap<String, String> queryParams) {
|
||||||
JsonObject obj = getJsonObj(string, queryParams);
|
JsonObject obj = getJsonObj(string, queryParams);
|
||||||
JsonArray arr = obj.getJsonArray("buckets");
|
JsonArray arr = obj.getJsonArray("buckets");
|
||||||
|
if (arr == null) {
|
||||||
|
return new long[0];
|
||||||
|
}
|
||||||
long res[] = new long[arr.size()];
|
long res[] = new long[arr.size()];
|
||||||
for (int i = 0; i< arr.size(); i++) {
|
for (int i = 0; i< arr.size(); i++) {
|
||||||
res[i] = arr.getJsonNumber(i).longValue();
|
res[i] = arr.getJsonNumber(i).longValue();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user