From c4b53fe936d68587bf4ab26f4c997cf7e2fc5859 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 27 Sep 2014 20:25:51 +0200 Subject: [PATCH] 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. --- .../java/net/pterodactylus/sone/core/SoneModificationDetector.java | 1 - .../net/pterodactylus/sone/core/SoneModificationDetectorTest.java | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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); -- 2.7.4