mirror of
https://github.com/corda/corda.git
synced 2024-12-20 05:28:21 +00:00
Remove usage of deprecated URLClassloader (re-coded without scanning and pattern matching on run-time classpath URLs)
This commit is contained in:
parent
e1d1563901
commit
077a2f5af6
@ -126,7 +126,7 @@ class DriverDSLImpl(
|
||||
private val state = ThreadBox(State())
|
||||
|
||||
//TODO: remove this once we can bundle quasar properly.
|
||||
private val quasarJarPath: String by lazy { resolveJar(".*quasar.*\\.jar$") }
|
||||
private val quasarJarPath: String by lazy { resolveJar("co.paralleluniverse.fibers.Suspendable") }
|
||||
|
||||
private fun NodeConfig.checkAndOverrideForInMemoryDB(): NodeConfig = this.run {
|
||||
if (inMemoryDB && corda.dataSourceProperties.getProperty("dataSource.url").startsWith("jdbc:h2:")) {
|
||||
@ -138,15 +138,13 @@ class DriverDSLImpl(
|
||||
}
|
||||
}
|
||||
|
||||
private fun resolveJar(jarNamePattern: String): String {
|
||||
private fun resolveJar(className: String): String {
|
||||
return try {
|
||||
val cl = ClassLoader.getSystemClassLoader()
|
||||
val urls = (cl as URLClassLoader).urLs
|
||||
val jarPattern = jarNamePattern.toRegex()
|
||||
val jarFileUrl = urls.first { jarPattern.matches(it.path) }
|
||||
jarFileUrl.toPath().toString()
|
||||
val type = Class.forName(className)
|
||||
val src = type.protectionDomain.codeSource
|
||||
return src.location.toString()
|
||||
} catch (e: Exception) {
|
||||
log.warn("Unable to locate JAR `$jarNamePattern` on classpath: ${e.message}", e)
|
||||
log.warn("Unable to locate JAR for class given by `$className` on classpath: ${e.message}", e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user