[test] Close the streams in the tests

This commit is contained in:
Andreas Dangel
2023-10-18 16:07:49 +02:00
parent fbf2f77871
commit e52fecc130

View File

@@ -188,7 +188,9 @@ abstract class BaseParsingHelper<Self : BaseParsingHelper<Self, T>, T : RootNode
val input = resourceLoader.getResourceAsStream(params.resourcePrefix + resourceName) val input = resourceLoader.getResourceAsStream(params.resourcePrefix + resourceName)
?: throw IllegalArgumentException("Unable to find resource file ${params.resourcePrefix + resourceName} from $resourceLoader") ?: throw IllegalArgumentException("Unable to find resource file ${params.resourcePrefix + resourceName} from $resourceLoader")
return consume(input) input.use {
return consume(input)
}
} }
private fun consume(input: InputStream) = private fun consume(input: InputStream) =
@@ -214,7 +216,9 @@ abstract class BaseParsingHelper<Self : BaseParsingHelper<Self, T>, T : RootNode
val input = (params.resourceLoader ?: javaClass).classLoader.getResourceAsStream(sourceFile) val input = (params.resourceLoader ?: javaClass).classLoader.getResourceAsStream(sourceFile)
?: throw IllegalArgumentException("Unable to find source file $sourceFile for $clazz") ?: throw IllegalArgumentException("Unable to find source file $sourceFile for $clazz")
return consume(input) input.use {
return consume(input)
}
} }
@JvmOverloads @JvmOverloads