Remove all existing posts of a Sone correctly.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 2 Jun 2014 04:40:42 +0000 (06:40 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 10 Jun 2014 10:45:03 +0000 (12:45 +0200)
src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java

index 61eb9be..238c533 100644 (file)
@@ -258,8 +258,8 @@ public class MemoryDatabase extends AbstractService implements Database {
                lock.writeLock().lock();
                try {
                        /* remove all posts by the Sone. */
-                       getPostsFrom(sone.getId()).clear();
-                       for (Post post : posts) {
+                       Collection<Post> oldPosts = getPostsFrom(sone.getId());
+                       for (Post post : oldPosts) {
                                allPosts.remove(post.getId());
                                if (post.getRecipientId().isPresent()) {
                                        getPostsTo(post.getRecipientId().get()).remove(post);