This repository was archived by the owner on Jul 25, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed
app/src/main/java/com/zulip/android/networking Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ public class HTTPRequest {
33
33
private OkHttpClient okHttpClient ;
34
34
private Response response = null ;
35
35
private String method , path ;
36
+ private Object synchronization = new Object ();
36
37
37
38
public void setMethodAndUrl (String method , String URL ) {
38
39
this .method = method ;
@@ -56,14 +57,22 @@ void clearProperties() {
56
57
57
58
void abort () {
58
59
aborting = true ;
59
- if (response != null ) {
60
- (new AsyncTask <Void , Void , Void >() {
61
- @ Override
62
- protected Void doInBackground (Void ... voids ) {
63
- response .body ().close ();
64
- return null ;
65
- }
66
- }).execute ();
60
+ synchronized (synchronization ) {
61
+ if (response != null ) {
62
+ final Response finalResponse = response ;
63
+ response = null ;
64
+ (new AsyncTask <Void , Void , Void >() {
65
+ @ Override
66
+ protected Void doInBackground (Void ... voids ) {
67
+ try {
68
+ finalResponse .body ().close ();
69
+ } catch (IllegalStateException e ) {
70
+ //fail silently
71
+ }
72
+ return null ;
73
+ }
74
+ }).execute ();
75
+ }
67
76
}
68
77
}
69
78
You can’t perform that action at this time.
0 commit comments