Only add get-trust jobs if there are none for the given identities yet.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 5 Sep 2012 10:26:32 +0000 (12:26 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 5 Sep 2012 10:26:32 +0000 (12:26 +0200)
src/main/java/net/pterodactylus/sone/core/TrustUpdater.java

index d122235..91e1783 100644 (file)
@@ -78,7 +78,15 @@ public class TrustUpdater extends AbstractService {
         *            The identity receiving the trust
         */
        public void getTrust(OwnIdentity truster, Identity trustee) {
-               updateJobs.add(new GetTrustJob(truster, trustee));
+               GetTrustJob getTrustJob = new GetTrustJob(truster, trustee);
+               if (!updateJobs.contains(getTrustJob)) {
+                       logger.log(Level.FINER, "Adding Trust Update Job: " + getTrustJob);
+                       try {
+                               updateJobs.put(getTrustJob);
+                       } catch (InterruptedException ie1) {
+                               /* the queue is unbounded so it should never block. */
+                       }
+               }
        }
 
        /**