Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
Correctness - Transient Incorrect Response
-
Low
-
Normal
-
User Report
-
All
-
None
-
Description
The output of nodetool tpstats -F json always prints an empty map for WaitLatencies:
$ nodetool tpstats -F json
(...)"WaitLatencies":{},(...)
The same happens with yaml output:
$ nodetool tpstats -F yaml (...) WaitLatencies: {} (...)
This happens because this cast silently fails inside a try-catch with an empty catch block:
String[] strValues = (String[]) Arrays.stream(probe.metricPercentilesAsArray(probe.getMessagingQueueWaitMetrics(entry.getKey()))) .map(D -> D.toString()) .toArray();
When we would need something like:
String[] strValues = Arrays.stream(probe.metricPercentilesAsArray(probe.getMessagingQueueWaitMetrics(entry.getKey()))) .map(Object::toString) .toArray(String[]::new);
This conversion from Double[] to String[] was introduced during CASSANDRA-16230. My guess is that the conversion was done trying to work around a malformed JSON output detected in the new tests added by that ticket. Without the conversion the output would be something like:
$ nodetool tpstats -F json (...)"WaitLatencies":{"READ_RSP":[Ljava.lang.Double;@398dada8,(...)
That's because json-simple doesn't handle well arrays. I think that instead of converting the array of doubles to an array of strings we can simply use jackson-mapper-asl to print the proper array.