mirror of
https://github.com/corda/corda.git
synced 2024-12-22 22:32:26 +00:00
CORDA-1113 - Close classloader (#2637)
* Close classloader after use (cherry picked from commit6070bc0
) * Better handling of classloader closing (cherry picked from commit2f6413b
)
This commit is contained in:
parent
78dbb96089
commit
4285000ff8
@ -24,9 +24,9 @@ fun scanJarForContracts(cordappJarPath: String): List<ContractClassName> {
|
||||
val contracts = (scanResult.getNamesOfClassesImplementing(Contract::class.qualifiedName) ).distinct()
|
||||
|
||||
// Only keep instantiable contracts
|
||||
val classLoader = URLClassLoader(arrayOf(File(cordappJarPath).toURL()), currentClassLoader)
|
||||
val concreteContracts = contracts.map(classLoader::loadClass).filter { !it.isInterface && !Modifier.isAbstract(it.modifiers) }
|
||||
return concreteContracts.map { it.name }
|
||||
return URLClassLoader(arrayOf(File(cordappJarPath).toURL()), currentClassLoader).use {
|
||||
contracts.map(it::loadClass).filter { !it.isInterface && !Modifier.isAbstract(it.modifiers) }
|
||||
}.map { it.name }
|
||||
}
|
||||
|
||||
fun <T> withContractsInJar(jarInputStream: InputStream, withContracts: (List<ContractClassName>, InputStream) -> T): T {
|
||||
|
Loading…
Reference in New Issue
Block a user