From: David ‘Bombe’ Roden Date: Tue, 6 Feb 2018 18:36:41 +0000 (+0100) Subject: Don’t load missing following times as Long.MAX_VALUE X-Git-Tag: v79^2~145 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=b91623458a0059ec31e6f57768b5814df97c093a;p=Sone.git Don’t load missing following times as Long.MAX_VALUE --- 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()) + } + }