Skip to content

Commit a0c3850

Browse files
committed
Add close to response events
1 parent 73975be commit a0c3850

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

android/app/src/main/java/com/httpsms/HttpSmsApiService.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {
9393

9494
val response = client.newCall(request).execute()
9595
if (!response.isSuccessful) {
96+
response.close()
9697
Timber.e("error response [${response.body?.string()}] with code [${response.code}] while receiving message [${body}]")
9798
return
9899
}
@@ -118,6 +119,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {
118119

119120
val response = client.newCall(request).execute()
120121
if (!response.isSuccessful) {
122+
response.close()
121123
Timber.e("error response [${response.body?.string()}] with code [${response.code}] while sending heartbeat [$body] for owner [$phoneNumber]")
122124
return
123125
}
@@ -153,6 +155,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {
153155

154156
val response = client.newCall(request).execute()
155157
if (!response.isSuccessful) {
158+
response.close()
156159
Timber.e("error response [${response.body?.string()}] with code [${response.code}] while sending [${event}] event [${body}] for message with ID [${messageId}]")
157160
return
158161
}
@@ -180,6 +183,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {
180183

181184
val response = client.newCall(request).execute()
182185
if (!response.isSuccessful) {
186+
response.close()
183187
Timber.e("error response [${response.body?.string()}] with code [${response.code}] while sending fcm token [${body}]")
184188
return null
185189
}
@@ -202,6 +206,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {
202206
try {
203207
val response = client.newCall(request).execute()
204208
if (!response.isSuccessful) {
209+
response.close()
205210
Timber.e("error response [${response.body?.string()}] with code [${response.code}] while verifying apiKey [$apiKey]")
206211
return Pair("Cannot validate the API key. Check if it is correct and try again.", null)
207212
}

0 commit comments

Comments
 (0)