Skip to content

Commit 9eb6f17

Browse files
committed
Fixed NPE in CompareMetrics
1 parent 52111fa commit 9eb6f17

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/org/jgroups/util/CompareMetrics.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ protected static void compareMetrics(Map<String,Collection<String>> new_metrics,
157157
String key=old_entry.getKey();
158158
Collection<String> old_attrs=old_entry.getValue();
159159
Collection<String> new_attrs=new_metrics.get(key);
160-
boolean rc=compareAttributes(new_attrs, old_attrs);
160+
boolean rc=new_attrs != null && compareAttributes(new_attrs, old_attrs);
161161
if(rc) {
162162
it.remove();
163163
new_metrics.remove(key);
@@ -179,7 +179,8 @@ protected static boolean compareAttributes(Collection<String> new_attrs, Collect
179179
}
180180

181181
protected static String print(Map<String,Collection<String>> map) {
182-
return map.entrySet().stream().map(e -> String.format("%s: %s", e.getKey(), e.getValue()))
182+
return map.entrySet().stream().filter(e -> e.getValue() != null && !e.getValue().isEmpty())
183+
.map(e -> String.format("%s: %s", e.getKey(), e.getValue()))
183184
.collect(Collectors.joining("\n"));
184185
}
185186

0 commit comments

Comments
 (0)