mirror of
https://github.com/corda/corda.git
synced 2024-12-23 06:42:33 +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()
|
val contracts = (scanResult.getNamesOfClassesImplementing(Contract::class.qualifiedName) ).distinct()
|
||||||
|
|
||||||
// Only keep instantiable contracts
|
// Only keep instantiable contracts
|
||||||
val classLoader = URLClassLoader(arrayOf(File(cordappJarPath).toURL()), currentClassLoader)
|
return URLClassLoader(arrayOf(File(cordappJarPath).toURL()), currentClassLoader).use {
|
||||||
val concreteContracts = contracts.map(classLoader::loadClass).filter { !it.isInterface && !Modifier.isAbstract(it.modifiers) }
|
contracts.map(it::loadClass).filter { !it.isInterface && !Modifier.isAbstract(it.modifiers) }
|
||||||
return concreteContracts.map { it.name }
|
}.map { it.name }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> withContractsInJar(jarInputStream: InputStream, withContracts: (List<ContractClassName>, InputStream) -> T): T {
|
fun <T> withContractsInJar(jarInputStream: InputStream, withContracts: (List<ContractClassName>, InputStream) -> T): T {
|
||||||
|
Loading…
Reference in New Issue
Block a user