From: David ‘Bombe’ Roden Date: Wed, 5 Aug 2020 20:28:15 +0000 (+0200) Subject: 🎨 Specify types of locks explicitely X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=8f223b8d369004637373003c9f6a294fe4af732d;p=Sone.git 🎨 Specify types of locks explicitely --- 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()