Don't access the Sone in the constructor.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 27 Sep 2014 18:25:51 +0000 (20:25 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 27 Sep 2014 18:30:04 +0000 (20:30 +0200)
Because of the initialization of a local Sone and its inserter the Sone
is currently not ready when the inserter and the modification detector
are being created. This needs to be fixed.

src/main/java/net/pterodactylus/sone/core/SoneModificationDetector.java
src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java

index 8b1b2ee..290fcbe 100644 (file)
@@ -38,7 +38,6 @@ class SoneModificationDetector {
                this.ticker = ticker;
                this.lockableFingerprintProvider = lockableFingerprintProvider;
                this.insertionDelay = insertionDelay;
-               originalFingerprint = lockableFingerprintProvider.getFingerprint();
                lastFingerprint = originalFingerprint;
        }
 
index e2b34f7..d70cc5c 100644 (file)
@@ -12,6 +12,7 @@ import net.pterodactylus.sone.core.SoneModificationDetector.LockableFingerprintP
 import net.pterodactylus.sone.data.Sone;
 
 import com.google.common.base.Ticker;
+import org.junit.Before;
 import org.junit.Test;
 
 /**
@@ -52,6 +53,11 @@ public class SoneModificationDetectorTest {
                when(lockableFingerprintProvider.isLocked()).thenReturn(false);
        }
 
+       @Before
+       public void setupOriginalFingerprint() {
+           soneModificationDetector.setFingerprint("original");
+       }
+
        @Test
        public void normalConstructorCanBeCalled() {
                new SoneModificationDetector(lockableFingerprintProvider, insertionDelay);