diff --git a/name.abuchen.portfolio/src/name/abuchen/portfolio/model/Client.java b/name.abuchen.portfolio/src/name/abuchen/portfolio/model/Client.java index 44957d14f2..5bc1c1fb27 100644 --- a/name.abuchen.portfolio/src/name/abuchen/portfolio/model/Client.java +++ b/name.abuchen.portfolio/src/name/abuchen/portfolio/model/Client.java @@ -29,7 +29,7 @@ public interface Properties // NOSONAR String WATCHLISTS = "watchlists"; //$NON-NLS-1$ } - public static final int CURRENT_VERSION = 59; + public static final int CURRENT_VERSION = 60; public static final int VERSION_WITH_CURRENCY_SUPPORT = 29; public static final int VERSION_WITH_UNIQUE_FILTER_KEY = 57; diff --git a/name.abuchen.portfolio/src/name/abuchen/portfolio/model/ClientFactory.java b/name.abuchen.portfolio/src/name/abuchen/portfolio/model/ClientFactory.java index 7fb3eff616..9ae5eac627 100644 --- a/name.abuchen.portfolio/src/name/abuchen/portfolio/model/ClientFactory.java +++ b/name.abuchen.portfolio/src/name/abuchen/portfolio/model/ClientFactory.java @@ -834,6 +834,8 @@ else if (flags.contains(SaveFlag.COMPRESSED)) removeWronglyAddedSecurities(client); case 58: fixDataSeriesLabelForAccumulatedTaxes(client); + case 59: + fixNullSecurityProperties(client); client.setVersion(Client.CURRENT_VERSION); break; @@ -1551,6 +1553,24 @@ private static void fixDataSeriesLabelForAccumulatedTaxes(Client client) .replace("Client-taxes;", "Client-taxes_accumulated;"))); //$NON-NLS-1$ //$NON-NLS-2$ } + private static void fixNullSecurityProperties(Client client) + { + // see https://github.com/portfolio-performance/portfolio/issues/3895 + + for (Security security : client.getSecurities()) + { + var properties = security.getProperties().toList(); + + for (SecurityProperty p : properties) + { + if (p == null) + { + security.removeProperty(null); + } + } + } + } + @SuppressWarnings("nls") private static synchronized XStream xstream() { diff --git a/name.abuchen.portfolio/src/name/abuchen/portfolio/model/ProtobufWriter.java b/name.abuchen.portfolio/src/name/abuchen/portfolio/model/ProtobufWriter.java index e7ce82cb19..3307f83bd8 100644 --- a/name.abuchen.portfolio/src/name/abuchen/portfolio/model/ProtobufWriter.java +++ b/name.abuchen.portfolio/src/name/abuchen/portfolio/model/ProtobufWriter.java @@ -881,6 +881,8 @@ private void saveSecurities(Client client, PClient.Builder newClient) Map data = new HashMap<>(); security.getProperties().forEach(p -> { + if (p == null) + return; PMap.Builder map = data.computeIfAbsent(p.getType().name(), k -> PMap.newBuilder()); map.addEntries(PKeyValue.newBuilder().setKey(p.getName()) .setValue(PAnyValue.newBuilder().setString(p.getValue())).build());