Skip to content

Commit

Permalink
[jacodb-api] For loading any SPI, do not use context classloader (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saloed authored Sep 16, 2024
1 parent 3377c0c commit c37de8f
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ open class SPILoader {
inline fun <reified T : CommonSPI> 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))
}
}
Expand Down

0 comments on commit c37de8f

Please sign in to comment.