Only create Sones if create is actually true.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 13 Oct 2011 04:14:56 +0000 (06:14 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 30 May 2012 07:42:53 +0000 (09:42 +0200)
src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java

index ff13faa..d87a712 100644 (file)
@@ -130,7 +130,7 @@ public class MemoryDatabase implements Database {
        public Sone getLocalSone(String id, boolean create) throws DatabaseException {
                Validation.begin().isNotNull("Sone ID", id).check();
                synchronized (localSones) {
-                       if (!localSones.containsKey(id)) {
+                       if (!localSones.containsKey(id) && create) {
                                localSones.put(id, new Sone(id));
                        }
                        return localSones.get(id);
@@ -144,7 +144,7 @@ public class MemoryDatabase implements Database {
        public Sone getRemoteSone(String id, boolean create) throws DatabaseException {
                Validation.begin().isNotNull("Sone ID", id).check();
                synchronized (remoteSones) {
-                       if (!remoteSones.containsKey(id)) {
+                       if (!remoteSones.containsKey(id) && create) {
                                remoteSones.put(id, new Sone(id));
                        }
                        return remoteSones.get(id);