mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-25 20:47:49 +02:00
close FileInputStreams to prevent resource leak
This commit is contained in:
@@ -50,8 +50,10 @@ class CrashReportCache(
|
||||
suspend fun loadAndDelete(): String? =
|
||||
withContext(Dispatchers.IO) {
|
||||
val stack =
|
||||
inputStreamOrNull()?.let { inStream ->
|
||||
InputStreamReader(inStream).readText()
|
||||
inputStreamOrNull()?.use { inStream ->
|
||||
InputStreamReader(inStream).use { reader ->
|
||||
reader.readText()
|
||||
}
|
||||
}
|
||||
deleteReport()
|
||||
stack
|
||||
|
@@ -73,7 +73,7 @@ abstract class OpCrypto internal constructor() : OpUnary() {
|
||||
}
|
||||
|
||||
@Throws(IOException::class, NoSuchAlgorithmException::class)
|
||||
fun hashFd(file: File?): ByteArray = hashFd(FileInputStream(file))
|
||||
fun hashFd(file: File?): ByteArray = FileInputStream(file).use { inputStream -> hashFd(inputStream) }
|
||||
|
||||
@Throws(IOException::class, NoSuchAlgorithmException::class)
|
||||
fun hashFd(bytes: ByteArray): ByteArray {
|
||||
|
Reference in New Issue
Block a user