Skip to content

Commit c446f5f

Browse files
resolve NPE in getTemplateGroupStatistics method
1 parent 927cacf commit c446f5f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/java/com/cisco/trex/stateful/TRexAstfClient.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,14 +472,13 @@ public Map<String, AstfStatistics> getTemplateGroupStatistics(
472472
MetaData metaData = getAstfStatsMetaData();
473473
name2Id.forEach(
474474
(tgName, tgId) -> {
475+
if (result.get(tgId.toString()) == null) {
476+
return;
477+
}
475478
try {
476479
AstfStatistics astfStatistics =
477480
new ObjectMapper()
478-
.readValue(
479-
Optional.ofNullable(result.get(tgId.toString()))
480-
.map(t -> t.toString())
481-
.orElse("{}"),
482-
AstfStatistics.class);
481+
.readValue(result.get(tgId.toString()).toString(), AstfStatistics.class);
483482
astfStatistics.setCounterNames(metaData);
484483
stats.put(tgName, astfStatistics);
485484
} catch (IOException e) {

0 commit comments

Comments
 (0)