Do not create a new Sone if the ID is obviously invalid.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / Core.java
index 0043feb..09e46b3 100644 (file)
@@ -528,7 +528,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
        public Sone getRemoteSone(String id, boolean create) {
                synchronized (remoteSones) {
                        Sone sone = remoteSones.get(id);
-                       if ((sone == null) && create) {
+                       if ((sone == null) && create && (id != null) && (id.length() == 43)) {
                                sone = new Sone(id);
                                remoteSones.put(id, sone);
                                setSoneStatus(sone, SoneStatus.unknown);
@@ -1070,7 +1070,6 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
                                        }
                                }
                        }
-                       remoteSones.put(identity.getId(), sone);
                        soneDownloader.addSone(sone);
                        setSoneStatus(sone, SoneStatus.unknown);
                        soneDownloaders.execute(new Runnable() {