From: David ‘Bombe’ Roden Date: Sun, 9 Apr 2017 19:40:18 +0000 (+0200) Subject: Fix some warnings X-Git-Tag: 0.9.7^2~247 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=7bb75fc81cd59d728fbc076a0d7356e43720c92a;p=Sone.git Fix some warnings --- diff --git a/src/main/kotlin/net/pterodactylus/sone/core/DefaultElementLoader.kt b/src/main/kotlin/net/pterodactylus/sone/core/DefaultElementLoader.kt index e07af93..5758c47 100644 --- a/src/main/kotlin/net/pterodactylus/sone/core/DefaultElementLoader.kt +++ b/src/main/kotlin/net/pterodactylus/sone/core/DefaultElementLoader.kt @@ -1,6 +1,7 @@ package net.pterodactylus.sone.core import com.google.common.base.Ticker +import com.google.common.cache.Cache import com.google.common.cache.CacheBuilder import freenet.keys.FreenetURI import java.io.ByteArrayInputStream @@ -17,9 +18,9 @@ class DefaultElementLoader(private val freenetInterface: FreenetInterface, ticke @Inject constructor(freenetInterface: FreenetInterface) : this(freenetInterface, Ticker.systemTicker()) - private val loadingLinks = CacheBuilder.newBuilder().build() - private val failureCache = CacheBuilder.newBuilder().ticker(ticker).expireAfterWrite(30, MINUTES).build() - private val imageCache = CacheBuilder.newBuilder().build() + private val loadingLinks: Cache = CacheBuilder.newBuilder().build() + private val failureCache: Cache = CacheBuilder.newBuilder().ticker(ticker).expireAfterWrite(30, MINUTES).build() + private val imageCache: Cache = CacheBuilder.newBuilder().build() private val callback = object : FreenetInterface.BackgroundFetchCallback { override fun shouldCancel(uri: FreenetURI, mimeType: String, size: Long): Boolean { return !mimeType.startsWith("image/") || (size > 2097152) @@ -66,7 +67,7 @@ class DefaultElementLoader(private val freenetInterface: FreenetInterface, ticke return LinkedElement(link, loading = true) } - private fun String.decode() = URLDecoder.decode(this, "UTF-8") - private fun String.normalize() = Normalizer.normalize(this, Normalizer.Form.NFC) + private fun String.decode() = URLDecoder.decode(this, "UTF-8")!! + private fun String.normalize() = Normalizer.normalize(this, Normalizer.Form.NFC)!! } diff --git a/src/test/kotlin/net/pterodactylus/sone/core/DefaultElementLoaderTest.kt b/src/test/kotlin/net/pterodactylus/sone/core/DefaultElementLoaderTest.kt index 5b84007..424aaff 100644 --- a/src/test/kotlin/net/pterodactylus/sone/core/DefaultElementLoaderTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/core/DefaultElementLoaderTest.kt @@ -27,8 +27,8 @@ class DefaultElementLoaderTest { private val freenetURI = FreenetURI(IMAGE_ID) private const val decomposedKey = "CHK@DCiVgTWW9nnWHJc9EVwtFJ6jAfBSVyy~rgiPvhUKbS4,mNY85V0x7dYcv7SnEYo1PCC6y2wNWMDNt-y9UWQx9fI,AAMC--8/fru%CC%88hstu%CC%88ck.jpg" private const val normalizedKey = "CHK@DCiVgTWW9nnWHJc9EVwtFJ6jAfBSVyy~rgiPvhUKbS4,mNY85V0x7dYcv7SnEYo1PCC6y2wNWMDNt-y9UWQx9fI,AAMC--8/frühstück.jpg" - private val sizeOkay = 2097152L; - private val sizeNotOkay = sizeOkay + 1; + private val sizeOkay = 2097152L + private val sizeNotOkay = sizeOkay + 1 } private val freenetInterface = mock()