From: David ‘Bombe’ Roden Date: Sat, 27 Sep 2014 18:25:51 +0000 (+0200) Subject: Don't access the Sone in the constructor. X-Git-Tag: 0.9-rc1^2~3^2~102 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c4b53fe936d68587bf4ab26f4c997cf7e2fc5859;p=Sone.git Don't access the Sone in the constructor. 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. --- diff --git a/src/main/java/net/pterodactylus/sone/core/SoneModificationDetector.java b/src/main/java/net/pterodactylus/sone/core/SoneModificationDetector.java index 8b1b2ee..290fcbe 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneModificationDetector.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneModificationDetector.java @@ -38,7 +38,6 @@ class SoneModificationDetector { this.ticker = ticker; this.lockableFingerprintProvider = lockableFingerprintProvider; this.insertionDelay = insertionDelay; - originalFingerprint = lockableFingerprintProvider.getFingerprint(); lastFingerprint = originalFingerprint; } diff --git a/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java b/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java index e2b34f7..d70cc5c 100644 --- a/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java +++ b/src/test/java/net/pterodactylus/sone/core/SoneModificationDetectorTest.java @@ -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);