Prevent null-pointer exception if property is missing
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 30 Nov 2017 05:23:22 +0000 (06:23 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 30 Nov 2017 05:23:22 +0000 (06:23 +0100)
src/main/java/net/pterodactylus/sone/core/Core.java

index 6292934..7384eda 100644 (file)
@@ -1712,7 +1712,13 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
                if (sone.isLocal()) {
                        return;
                }
-               sone.setLatestEdition(fromNullable(tryParse(identity.getProperty("Sone.LatestEdition"))).or(sone.getLatestEdition()));
+               String newLatestEdition = identity.getProperty("Sone.LatestEdition");
+               if (newLatestEdition != null) {
+                       Long parsedNewLatestEdition = tryParse(newLatestEdition);
+                       if (parsedNewLatestEdition != null) {
+                               sone.setLatestEdition(parsedNewLatestEdition);
+                       }
+               }
                soneDownloader.addSone(sone);
                soneDownloaders.execute(soneDownloader.fetchSoneAction(sone));
        }