Use a real boolean to signal that the Sone should be inserted now.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 11 Jun 2014 04:28:25 +0000 (06:28 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 11 Jun 2014 04:28:25 +0000 (06:28 +0200)
src/main/java/net/pterodactylus/sone/core/SoneInserter.java

index d5fe9a2..1445613 100644 (file)
@@ -212,7 +212,7 @@ public class SoneInserter extends AbstractService {
                                        continue;
                                }
 
-                               InsertInformation insertInformation = null;
+                               boolean insertSoneNow = false;
                                synchronized (sone) {
                                        String fingerprint = sone.getFingerprint();
                                        if (!fingerprint.equals(lastFingerprint)) {
@@ -229,11 +229,12 @@ public class SoneInserter extends AbstractService {
                                        }
                                        if (modified && lastModificationTime.isPresent() && ((currentTimeMillis() - lastModificationTime.get()) > (insertionDelay * 1000))) {
                                                lastInsertedFingerprint = fingerprint;
-                                               insertInformation = new InsertInformation(sone);
+                                               insertSoneNow = true;
                                        }
                                }
 
-                               if (insertInformation != null) {
+                               if (insertSoneNow) {
+                                       InsertInformation insertInformation = new InsertInformation(sone);
                                        logger.log(Level.INFO, String.format("Inserting Sone “%s”…", sone.getName()));
 
                                        boolean success = false;