File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
core/src/main/java/com/cloudinary/android Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -108,11 +108,9 @@ public boolean cancelRequest(String requestId) {
108108 return operation .getResult ().isCancelled ();
109109 }
110110
111- @ Override
112111 public int cancelAllRequests () {
113112 WorkManager .getInstance (context ).cancelAllWork ();
114- killAllThreads ();
115- return 0 ;
113+ return killAllThreads ();
116114 }
117115
118116 private void killThread (String requestId ) {
@@ -129,8 +127,9 @@ private void killThread(String requestId) {
129127 }
130128 }
131129
132- private void killAllThreads () {
130+ private int killAllThreads () {
133131 synchronized (threadsMapLockObject ) {
132+ int size = threads .size ();
134133 for (String requestId : threads .keySet ()) {
135134 WeakReference <Thread > ref = threads .get (requestId );
136135 Thread thread = ref .get ();
@@ -141,8 +140,8 @@ private void killAllThreads() {
141140
142141 ref .clear ();
143142 }
144-
145143 threads .clear ();
144+ return size ;
146145 }
147146 }
148147
Original file line number Diff line number Diff line change 1313import java .io .File ;
1414import java .io .IOException ;
1515import java .io .InputStream ;
16+ import java .io .InterruptedIOException ;
1617import java .net .HttpURLConnection ;
1718import java .util .Collection ;
1819import java .util .Map ;
@@ -73,7 +74,7 @@ public void totalBytesLoaded(long bytes) {
7374 }
7475
7576 MultipartUtility multipart = null ;
76- HttpURLConnection connection ;
77+ HttpURLConnection connection = null ;
7778
7879 try {
7980 int connectTimeout = options .get ("connect_timeout" ) != null ? (int ) options .get ("connect_timeout" ) : 0 ;
@@ -108,6 +109,8 @@ public void totalBytesLoaded(long bytes) {
108109 }
109110
110111 connection = multipart .execute ();
112+ } catch (InterruptedIOException e ) {
113+ e .printStackTrace ();
111114 } finally {
112115 if (multipart != null ){
113116 // Closing more than once has no effect so we can call it safely without having to check state
You can’t perform that action at this time.
0 commit comments