Skip to content

Commit 0f3ee08

Browse files
committed
Fix storage deserialization crash on unknown actions value
1 parent 4ed935d commit 0f3ee08

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.4.2
2+
* Fix storage deserialization crash on unknown actions value #273
3+
14
## 1.4.1
25
* Fix ``Add class qualifier to static member access outside declaring class`` not working correctly for ``switch`` statements #263
36

src/main/java/software/xdev/saveactions/model/Storage.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package software.xdev.saveactions.model;
22

33
import java.util.ArrayList;
4-
import java.util.EnumSet;
54
import java.util.HashSet;
65
import java.util.List;
76
import java.util.Objects;
@@ -31,7 +30,9 @@ public final class Storage implements PersistentStateComponent<Storage>
3130
public Storage()
3231
{
3332
this.firstLaunch = true;
34-
this.actions = EnumSet.noneOf(Action.class);
33+
// Must use a set that support nullable values!
34+
// For example EnumSet will crash when encountering an unknown/null value
35+
this.actions = new HashSet<>();
3536
this.exclusions = new HashSet<>();
3637
this.inclusions = new HashSet<>();
3738
this.configurationPath = null;
@@ -42,7 +43,7 @@ public Storage()
4243
public Storage(final Storage storage)
4344
{
4445
this.firstLaunch = storage.firstLaunch;
45-
this.actions = EnumSet.copyOf(storage.actions);
46+
this.actions = new HashSet<>(storage.actions);
4647
this.exclusions = new HashSet<>(storage.exclusions);
4748
this.inclusions = new HashSet<>(storage.inclusions);
4849
this.configurationPath = storage.configurationPath;

0 commit comments

Comments
 (0)