Skip to content

Commit

Permalink
fix(core): fix NPE on ImmutableStateChangeList when no changes (#461)
Browse files Browse the repository at this point in the history
fix: #461
  • Loading branch information
fhussonnois committed Jun 4, 2024
1 parent 0c57f6b commit 563e256
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ public final class ImmutableStateChangeList<T extends StateChange> implements It
*/
ImmutableStateChangeList(final List<T> values) {
Map<String, List<T>> all = new LinkedHashMap<>();
values.forEach(data -> {
if (data != null) {
all.computeIfAbsent(data.getName(), unused -> new LinkedList<>()).add(data);
}
});
this.changes = Collections.unmodifiableList(values);
if (values != null) {
values.forEach(data -> {
if (data != null) {
all.computeIfAbsent(data.getName(), unused -> new LinkedList<>()).add(data);
}
});
this.changes = Collections.unmodifiableList(values);
} else {
this.changes = Collections.emptyList();
}
this.changesByName = Collections.unmodifiableMap(all);
}

Expand Down

0 comments on commit 563e256

Please sign in to comment.