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()
|
Request.Builder().url(apiUrl).post(formBody).header("User-Agent", buildUserAgent()).build()
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
val result = client.newCall(request).execute()
|
client.newCall(request).execute().use { result ->
|
||||||
httpStatusCode = result.code
|
httpStatusCode = result.code
|
||||||
proTip = result.header("x-akismet-pro-tip", "").toString().trim()
|
proTip = result.header("x-akismet-pro-tip", "").toString().trim()
|
||||||
isDiscard = (proTip == "discard")
|
isDiscard = (proTip == "discard")
|
||||||
|
@ -352,6 +352,7 @@ open class Akismet(apiKey: String) {
|
||||||
message
|
message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
errorMessage = "An IO error occurred while communicating with the Akismet service: ${e.message}"
|
errorMessage = "An IO error occurred while communicating with the Akismet service: ${e.message}"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue