Fixed potential resource leak
This commit is contained in:
parent
d525910145
commit
a918fdf107
1 changed files with 19 additions and 18 deletions
|
@ -331,7 +331,7 @@ open class Akismet(apiKey: String) {
|
|||
Request.Builder().url(apiUrl).post(formBody).header("User-Agent", buildUserAgent()).build()
|
||||
}
|
||||
try {
|
||||
val result = client.newCall(request).execute()
|
||||
client.newCall(request).execute().use { result ->
|
||||
httpStatusCode = result.code
|
||||
proTip = result.header("x-akismet-pro-tip", "").toString().trim()
|
||||
isDiscard = (proTip == "discard")
|
||||
|
@ -352,6 +352,7 @@ open class Akismet(apiKey: String) {
|
|||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
errorMessage = "An IO error occurred while communicating with the Akismet service: ${e.message}"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue