Skip to content

Commit

Permalink
Fix client service loader on the android
Browse files Browse the repository at this point in the history
  • Loading branch information
e5l authored and Sergey Mashkov committed Sep 18, 2018
1 parent 4d077f6 commit 330ed1e
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ interface HttpClientEngineContainer {
val factory: HttpClientEngineFactory<*>
}

private val FACTORY = ServiceLoader.load(HttpClientEngineContainer::class.java)
.toList()
.firstOrNull()
?.factory ?: error("Failed to find HttpClientEngineContainer in classpath via ServiceLoader")
/**
* Workaround for dummy android [ClassLoader].
*/
private val engines: List<HttpClientEngineContainer> = HttpClientEngineContainer::class.java.let {
ServiceLoader.load(it, it.classLoader).toList()
}

private val FACTORY = engines.firstOrNull()?.factory
?: error("Failed to find HttpClientEngineContainer in classpath via ServiceLoader")

0 comments on commit 330ed1e

Please sign in to comment.