Skip to content

Commit

Permalink
[resources] Properly close input stream when read resource bytes.
Browse files Browse the repository at this point in the history
  • Loading branch information
terrakok committed Jun 20, 2024
1 parent 8fc3dd2 commit be4dfa4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal actual fun getPlatformResourceReader(): ResourceReader = object : Resou

override suspend fun read(path: String): ByteArray {
val resource = getResourceAsStream(path)
return resource.readBytes()
return resource.use { input -> input.readBytes() }
}

override suspend fun readPart(path: String, offset: Long, size: Long): ByteArray {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.io.InputStream
internal actual fun getPlatformResourceReader(): ResourceReader = object : ResourceReader {
override suspend fun read(path: String): ByteArray {
val resource = getResourceAsStream(path)
return resource.readBytes()
return resource.use { input -> input.readBytes() }
}

override suspend fun readPart(path: String, offset: Long, size: Long): ByteArray {
Expand Down

0 comments on commit be4dfa4

Please sign in to comment.