diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt index 6e31b40285..46c3d9b272 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt @@ -188,7 +188,9 @@ abstract class BaseParsingHelper, T : RootNode val input = resourceLoader.getResourceAsStream(params.resourcePrefix + resourceName) ?: 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) = @@ -214,7 +216,9 @@ abstract class BaseParsingHelper, T : RootNode val input = (params.resourceLoader ?: javaClass).classLoader.getResourceAsStream(sourceFile) ?: throw IllegalArgumentException("Unable to find source file $sourceFile for $clazz") - return consume(input) + input.use { + return consume(input) + } } @JvmOverloads