Skip to content

Commit

Permalink
Merge pull request #305 from assimbly/fix/cpu-load-parse-double-empty…
Browse files Browse the repository at this point in the history
…-string

Flow stats - cpu load - use 0 if string cannot be parsed
  • Loading branch information
skin27 authored Nov 5, 2024
2 parents a03b53a + fb3a657 commit c85e5bd
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2174,9 +2174,9 @@ public String getFlowStats(String flowId, boolean fullStats, boolean includeMeta
}
}

cpuLoadLastMinute += Double.parseDouble(route.getLoad01());
cpuLoadLast5Minutes += Double.parseDouble(route.getLoad05());
cpuLoadLast15Minutes += Double.parseDouble(route.getLoad15());
cpuLoadLastMinute += ParseDouble(route.getLoad01());
cpuLoadLast5Minutes += ParseDouble(route.getLoad05());
cpuLoadLast15Minutes += ParseDouble(route.getLoad15());

if(includeSteps){
JSONObject step = getStepStats(routeId, fullStats);
Expand Down Expand Up @@ -3130,4 +3130,15 @@ private String getKeystorePassword() {
return keystorePwd;
}

private double ParseDouble(String strNumber) {
if (strNumber != null && strNumber.length() > 0) {
try {
return Double.parseDouble(strNumber);
} catch(Exception e) {
return 0;
}
}
return 0;
}

}

0 comments on commit c85e5bd

Please sign in to comment.