From b91623458a0059ec31e6f57768b5814df97c093a Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 6 Feb 2018 19:36:41 +0100 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20load=20missing=20following=20tim?= =?utf8?q?es=20as=20Long.MAX=5FVALUE?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../sone/database/memory/ConfigurationLoader.java | 2 +- .../sone/database/memory/ConfigurationLoaderTest.kt | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/database/memory/ConfigurationLoader.java b/src/main/java/net/pterodactylus/sone/database/memory/ConfigurationLoader.java index bb82ee2..e471f0d 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/ConfigurationLoader.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/ConfigurationLoader.java @@ -75,7 +75,7 @@ public class ConfigurationLoader { if (soneId == null) { break; } - soneFollowingTimes.put(soneId, configuration.getLongValue("SoneFollowingTimes/" + soneCounter++ + "/Time").getValue(Long.MAX_VALUE)); + soneFollowingTimes.put(soneId, configuration.getLongValue("SoneFollowingTimes/" + soneCounter++ + "/Time").getValue(null)); } return soneFollowingTimes; } diff --git a/src/test/kotlin/net/pterodactylus/sone/database/memory/ConfigurationLoaderTest.kt b/src/test/kotlin/net/pterodactylus/sone/database/memory/ConfigurationLoaderTest.kt index b2da512..f653251 100644 --- a/src/test/kotlin/net/pterodactylus/sone/database/memory/ConfigurationLoaderTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/database/memory/ConfigurationLoaderTest.kt @@ -109,4 +109,16 @@ class ConfigurationLoaderTest { assertThat(sone2Id.value, nullValue()) } + @Test + fun `sone with missing following time is not loaded`() { + setupStringValue("SoneFollowingTimes/0/Sone", "Sone1") + setupLongValue("SoneFollowingTimes/0/Time", 1000L) + setupStringValue("SoneFollowingTimes/1/Sone", "Sone2") + setupLongValue("SoneFollowingTimes/1/Time") + setupStringValue("SoneFollowingTimes/2/Sone") + assertThat(configurationLoader.getSoneFollowingTime("Sone1"), equalTo(1000L)) + assertThat(configurationLoader.getSoneFollowingTime("Sone2"), nullValue()) + assertThat(configurationLoader.getSoneFollowingTime("Sone3"), nullValue()) + } + } -- 2.7.4