[JS] Replace usages of FileUtil.loadTextAndClose with functions from stdlib to avoid crashes on files larger than 10MiB

This commit is contained in:
Zalim Bashorov
2021-01-28 21:49:27 +03:00
committed by Anton Bannykh
parent 165533fdb7
commit 3f10914f05
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -150,7 +150,7 @@ object JsLibraryUtils {
val relativePath = getSuggestedPath(entryName) ?: continue val relativePath = getSuggestedPath(entryName) ?: continue
val stream = zipFile.getInputStream(entry) val stream = zipFile.getInputStream(entry)
val content = FileUtil.loadTextAndClose(stream) val content = stream.reader().readText()
librariesWithoutSourceMaps += JsLibrary(content, relativePath, null, null) librariesWithoutSourceMaps += JsLibrary(content, relativePath, null, null)
} }
else if (entryName.endsWith(KotlinJavascriptMetadataUtils.JS_MAP_EXT)) { else if (entryName.endsWith(KotlinJavascriptMetadataUtils.JS_MAP_EXT)) {
@@ -166,7 +166,7 @@ object JsLibraryUtils {
val zipEntry = possibleMapFiles[it.path] val zipEntry = possibleMapFiles[it.path]
if (zipEntry != null) { if (zipEntry != null) {
val stream = zipFile.getInputStream(zipEntry) val stream = zipFile.getInputStream(zipEntry)
val content = FileUtil.loadTextAndClose(stream) val content = stream.reader().readText()
it.copy(sourceMapContent = content) it.copy(sourceMapContent = content)
} }
else { else {