mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 03:48:34 +00:00
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:
parent
453996c374
commit
e3ea36c76f
@ -13,6 +13,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.net.SocketException;
|
||||||
|
|
||||||
public class EncryptedCacheEncoder extends EncryptedCoder implements Encoder<InputStream> {
|
public class EncryptedCacheEncoder extends EncryptedCoder implements Encoder<InputStream> {
|
||||||
|
|
||||||
@ -42,12 +43,14 @@ public class EncryptedCacheEncoder extends EncryptedCoder implements Encoder<Inp
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.w(TAG, e);
|
if (e instanceof SocketException) {
|
||||||
|
Log.d(TAG, "Socket exception. Likely a cancellation.");
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, e);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
byteArrayPool.put(buffer);
|
byteArrayPool.put(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import android.os.AsyncTask;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.WorkerThread;
|
import androidx.annotation.WorkerThread;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
import org.whispersystems.libsignal.util.guava.Optional;
|
||||||
|
|
||||||
@ -29,22 +30,13 @@ public class CallRequestController implements RequestController {
|
|||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
|
|
||||||
call.cancel();
|
call.cancel();
|
||||||
|
|
||||||
if (stream != null) {
|
|
||||||
Util.close(stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
canceled = true;
|
canceled = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void setStream(@NonNull InputStream stream) {
|
public synchronized void setStream(@NonNull InputStream stream) {
|
||||||
if (canceled) {
|
this.stream = stream;
|
||||||
Util.close(stream);
|
|
||||||
} else {
|
|
||||||
this.stream = stream;
|
|
||||||
}
|
|
||||||
notifyAll();
|
notifyAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user