Remove unnecessary okhttp close when canceling.

Canceling should handle closing stuff now. And if we close from a
different thread than the calling thread, okhttp will crash.
This commit is contained in:
Greyson Parrelli
2020-03-19 10:04:04 -04:00
parent 453996c374
commit e3ea36c76f
2 changed files with 9 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ import android.os.AsyncTask;
import androidx.annotation.NonNull;
import androidx.annotation.WorkerThread;
import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.libsignal.util.guava.Optional;
@@ -27,24 +28,15 @@ public class CallRequestController implements RequestController {
AsyncTask.THREAD_POOL_EXECUTOR.execute(() -> {
synchronized (CallRequestController.this) {
if (canceled) return;
call.cancel();
if (stream != null) {
Util.close(stream);
}
canceled = true;
}
});
}
public synchronized void setStream(@NonNull InputStream stream) {
if (canceled) {
Util.close(stream);
} else {
this.stream = stream;
}
this.stream = stream;
notifyAll();
}