Add synchronization.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 1 Apr 2011 10:35:29 +0000 (12:35 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 1 Apr 2011 10:35:29 +0000 (12:35 +0200)
This has been noticed by FindBugs.

src/main/java/net/pterodactylus/sone/data/Sone.java

index a1aa6ee..e5695fa 100644 (file)
@@ -397,8 +397,10 @@ public class Sone implements Fingerprintable, Comparable<Sone> {
         * @return This Sone (for method chaining)
         */
        public synchronized Sone setPosts(Collection<Post> posts) {
-               this.posts.clear();
-               this.posts.addAll(posts);
+               synchronized (this) {
+                       this.posts.clear();
+                       this.posts.addAll(posts);
+               }
                return this;
        }