diff --git a/jacodb-api-jvm/src/main/kotlin/org/jacodb/api/jvm/spi/SPILoader.kt b/jacodb-api-jvm/src/main/kotlin/org/jacodb/api/jvm/spi/SPILoader.kt index d134156b9..55d40b0bd 100644 --- a/jacodb-api-jvm/src/main/kotlin/org/jacodb/api/jvm/spi/SPILoader.kt +++ b/jacodb-api-jvm/src/main/kotlin/org/jacodb/api/jvm/spi/SPILoader.kt @@ -27,11 +27,7 @@ open class SPILoader { inline fun loadSPI(id: String): T? { return spiCache[id]?.get() as? T ?: run { val clazz = T::class.java - var serviceLoader = ServiceLoader.load(clazz) - if (!serviceLoader.iterator().hasNext()) { - serviceLoader = ServiceLoader.load(clazz, clazz.getClassLoader()) - } - serviceLoader.find { it.id == id }?.also { + ServiceLoader.load(clazz, clazz.getClassLoader()).find { it.id == id }?.also { spiCache.putIfAbsent(id, SoftReference(it)) } }