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