From 8f223b8d369004637373003c9f6a294fe4af732d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 5 Aug 2020 22:28:15 +0200 Subject: [PATCH] =?utf8?q?=F0=9F=8E=A8=20Specify=20types=20of=20locks=20ex?= =?utf8?q?plicitely?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../kotlin/net/pterodactylus/sone/database/memory/MemoryDatabase.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/database/memory/MemoryDatabase.kt b/src/main/kotlin/net/pterodactylus/sone/database/memory/MemoryDatabase.kt index d48ef1e..ad7ab07 100644 --- a/src/main/kotlin/net/pterodactylus/sone/database/memory/MemoryDatabase.kt +++ b/src/main/kotlin/net/pterodactylus/sone/database/memory/MemoryDatabase.kt @@ -47,6 +47,8 @@ import net.pterodactylus.sone.utils.unit import net.pterodactylus.util.config.Configuration import net.pterodactylus.util.config.ConfigurationException import java.util.concurrent.locks.ReentrantReadWriteLock +import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock +import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock import kotlin.concurrent.withLock /** @@ -56,8 +58,8 @@ import kotlin.concurrent.withLock class MemoryDatabase @Inject constructor(private val configuration: Configuration) : AbstractService(), Database { private val lock = ReentrantReadWriteLock() - private val readLock by lazy { lock.readLock()!! } - private val writeLock by lazy { lock.writeLock()!! } + private val readLock: ReadLock by lazy { lock.readLock() } + private val writeLock: WriteLock by lazy { lock.writeLock() } private val configurationLoader = ConfigurationLoader(configuration) private val allSones = mutableMapOf() private val allPosts = mutableMapOf() -- 2.7.4