mirror of
https://github.com/corda/corda.git
synced 2025-01-31 08:25:50 +00:00
CORDA-2157: Close inputStream
properly in withContractsInJar (#4365)
Or else the file remains open and test `VaultQueryJavaTests.testAttachmentQueryCriteria` fails on Windows as open for reading files cannot be deleted.
This commit is contained in:
parent
42252cd967
commit
5ad992d01f
@ -51,7 +51,9 @@ private val logger = LoggerFactory.getLogger("ClassloaderUtils")
|
||||
fun <T> withContractsInJar(jarInputStream: InputStream, withContracts: (List<ContractClassName>, InputStream) -> T): T {
|
||||
val tempFile = Files.createTempFile("attachment", ".jar")
|
||||
try {
|
||||
jarInputStream.copyTo(tempFile, StandardCopyOption.REPLACE_EXISTING)
|
||||
jarInputStream.use {
|
||||
it.copyTo(tempFile, StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
val cordappJar = tempFile.toAbsolutePath()
|
||||
val contracts = logElapsedTime("Contracts loading for '$cordappJar'", logger) {
|
||||
ContractsJarFile(tempFile.toAbsolutePath()).scan()
|
||||
|
Loading…
x
Reference in New Issue
Block a user