Skip to content

Commit 1615e52

Browse files
committed
BAEL-9401: use a defensive copy for list
1 parent 8ea2547 commit 1615e52

File tree

1 file changed

+1
-2
lines changed
  • patterns-modules/data-oriented-programming/src/main/java/com/baeldung/patterns/data

1 file changed

+1
-2
lines changed

patterns-modules/data-oriented-programming/src/main/java/com/baeldung/patterns/data/Roll.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public record Roll(List<Integer> dice, int rollCount) {
99
throw new IllegalArgumentException("A Roll needs to have exactly 5 dice.");
1010
if (dice.stream().anyMatch(die -> die < 1 || die > 6))
1111
throw new IllegalArgumentException("Dice values should be between 1 and 6.");
12-
13-
dice = Collections.unmodifiableList(dice);
12+
dice = List.copyOf(dice);
1413
}
1514
}

0 commit comments

Comments
 (0)