Fixed potential resource leak

This commit is contained in:
Erik C. Thauvin 2023-01-31 22:05:16 -08:00
parent d2389088ac
commit ac94ac7d29

View file

@ -56,9 +56,11 @@ class Isgd private constructor() {
"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/109.0" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/109.0"
) )
if (connection.responseCode in 200..399) { if (connection.responseCode in 200..399) {
return connection.inputStream.bufferedReader().readText() return connection.inputStream.bufferedReader().use { it.readText() }
} else { } else {
throw IsgdException(connection.responseCode, connection.errorStream.bufferedReader().readText()) throw IsgdException(
connection.responseCode,
connection.errorStream.bufferedReader().use { it.readText() })
} }
} }