forked from phoedos/pmd
[test] Close the streams in the tests
This commit is contained in:
@@ -188,8 +188,10 @@ 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")
|
||||||
|
|
||||||
|
input.use {
|
||||||
return consume(input)
|
return consume(input)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun consume(input: InputStream) =
|
private fun consume(input: InputStream) =
|
||||||
IOUtil.readToString(input, StandardCharsets.UTF_8)
|
IOUtil.readToString(input, StandardCharsets.UTF_8)
|
||||||
@@ -214,8 +216,10 @@ 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")
|
||||||
|
|
||||||
|
input.use {
|
||||||
return consume(input)
|
return consume(input)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun newXpathRule(expr: String, version: XPathVersion = XPathVersion.DEFAULT) =
|
fun newXpathRule(expr: String, version: XPathVersion = XPathVersion.DEFAULT) =
|
||||||
|
Reference in New Issue
Block a user