Fix multiple resource leaks by closing InputStream instances

The main fix is in BuiltInsPackageFragment, the rest is the improvement of
other usages of getResourceAsStream

 #KT-11433 Fixed
This commit is contained in:
Alexander Udalov
2016-03-29 13:20:14 +03:00
parent 8316953259
commit 0ea3b4ade4
6 changed files with 32 additions and 34 deletions
@@ -25,7 +25,7 @@ class RuntimePackagePartProvider(private val classLoader: ClassLoader) : Package
fun registerModule(moduleName: String) {
val mapping = try {
classLoader.getResourceAsStream("META-INF/$moduleName.${ModuleMapping.MAPPING_FILE_EXT}")?.let { stream ->
classLoader.getResourceAsStream("META-INF/$moduleName.${ModuleMapping.MAPPING_FILE_EXT}")?.use { stream ->
ModuleMapping.create(stream.readBytes())
}
}