Azure / azure-storage-android

Microsoft Azure Storage Library for Android
Apache License 2.0
81 stars 48 forks source link

close input and output stream of request #85

Open dpproduction opened 3 years ago

dpproduction commented 3 years ago

Strict mode shows that closeable resource was not closed.

I have added a call to the close method for input and output stream of http request.

2021-01-25 17:42:32.911 1958-1967/com.sportics.horbikeapplication E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. java.lang.Throwable: Explicit termination method 'close' not called at dalvik.system.CloseGuard.open(CloseGuard.java:180) at java.net.AbstractPlainSocketImpl.create(AbstractPlainSocketImpl.java:103) at java.net.Socket.createImpl(Socket.java:464) at java.net.Socket.getImpl(Socket.java:530) at java.net.Socket.setSoSndTimeout(Socket.java:1194) at com.android.okhttp.Connection.setTimeouts(Connection.java:508) at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:400) at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:130) at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:356) at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:273) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:478) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:261) at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218) at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java) at com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:90) at com.microsoft.azure.storage.blob.CloudBlockBlob.uploadFullBlob(CloudBlockBlob.java:726) at com.microsoft.azure.storage.blob.CloudBlockBlob.upload(CloudBlockBlob.java:679) at com.microsoft.azure.storage.blob.CloudBlob.uploadFromByteArray(CloudBlob.java:1665) at com.microsoft.azure.storage.blob.CloudBlockBlob.uploadText(CloudBlockBlob.java:1014) at com.microsoft.azure.storage.blob.CloudBlockBlob.uploadText(CloudBlockBlob.java:984) at com.sportics.horbikeapplication.repositories.azure.AzureBikeInfoUploader.uploadData(AzureBikeInfoUploader.kt:25) at com.sportics.horbikeapplication.repositories.azure.AzureStorageUploadWorker$doWork$2.invokeSuspend(AzureStorageUploadWorker.kt:31) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665) 2021-01-25 17:42:32.913 1958-1967/com.sportics.horbikeapplication E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. java.lang.Throwable: Explicit termination method 'close' not called at dalvik.system.CloseGuard.open(CloseGuard.java:180) at java.net.AbstractPlainSocketImpl.create(AbstractPlainSocketImpl.java:103) at java.net.Socket.createImpl(Socket.java:464) at java.net.Socket.getImpl(Socket.java:530) at java.net.Socket.setSoSndTimeout(Socket.java:1194) at com.android.okhttp.Connection.setTimeouts(Connection.java:508) at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:400) at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:130) at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:356) at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:273) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:478) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:426) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:542) at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105) at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java) at com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:106) at com.microsoft.azure.storage.blob.CloudBlob.exists(CloudBlob.java:1831) at com.microsoft.azure.storage.blob.CloudBlob.exists(CloudBlob.java:1818) at com.microsoft.azure.storage.blob.CloudBlob.exists(CloudBlob.java:1793) at com.sportics.horbikeapplication.repositories.azure.AzureLogsUploader.calcLengthDiff(AzureLogsUploader.kt:47) at com.sportics.horbikeapplication.repositories.azure.AzureLogsUploader.uploadData(AzureLogsUploader.kt:29) at com.sportics.horbikeapplication.repositories.azure.AzureStorageUploadWorker$doWork$2.invokeSuspend(AzureStorageUploadWorker.kt:31) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665) _

ghost commented 3 years ago

CLA assistant check
All CLA requirements met.