Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.4.2
* Fix storage deserialization crash on unknown actions value #273

## 1.4.1
* Fix ``Add class qualifier to static member access outside declaring class`` not working correctly for ``switch`` statements #263

Expand Down
8 changes: 5 additions & 3 deletions src/main/java/software/xdev/saveactions/model/Storage.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package software.xdev.saveactions.model;

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
Expand All @@ -18,9 +17,12 @@

@State(name = "SaveActionSettings", storages = {@com.intellij.openapi.components.Storage("saveactions_settings.xml")})
@Service(Service.Level.PROJECT)
@SuppressWarnings("PMD.UseEnumCollections") // Set must be nullable!
public final class Storage implements PersistentStateComponent<Storage>
{
private boolean firstLaunch;
// Must use a set that supports nullable values!
// For example EnumSet will crash when encountering an unknown/null value
private Set<Action> actions;
private Set<String> exclusions;
private Set<String> inclusions;
Expand All @@ -31,7 +33,7 @@ public final class Storage implements PersistentStateComponent<Storage>
public Storage()
{
this.firstLaunch = true;
this.actions = EnumSet.noneOf(Action.class);
this.actions = new HashSet<>();
this.exclusions = new HashSet<>();
this.inclusions = new HashSet<>();
this.configurationPath = null;
Expand All @@ -42,7 +44,7 @@ public Storage()
public Storage(final Storage storage)
{
this.firstLaunch = storage.firstLaunch;
this.actions = EnumSet.copyOf(storage.actions);
this.actions = new HashSet<>(storage.actions);
this.exclusions = new HashSet<>(storage.exclusions);
this.inclusions = new HashSet<>(storage.inclusions);
this.configurationPath = storage.configurationPath;
Expand Down