Fix DownloadService deadlock
downloadExecutor.take() clears the interrupted state of the thread when throwing an InterruptedException. When getting this exception, we need to return instead of relying on the loop to get cancelled.
This commit is contained in:
parent
a99a41e3bb
commit
4530413d97
|
@ -260,7 +260,6 @@ public class DownloadService extends Service {
|
||||||
removeDownload(downloader);
|
removeDownload(downloader);
|
||||||
numberOfDownloads.decrementAndGet();
|
numberOfDownloads.decrementAndGet();
|
||||||
queryDownloadsAsync();
|
queryDownloadsAsync();
|
||||||
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
handleFailedDownload(downloader);
|
handleFailedDownload(downloader);
|
||||||
|
@ -270,8 +269,10 @@ public class DownloadService extends Service {
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Log.e(TAG, "DownloadCompletionThread was interrupted");
|
Log.e(TAG, "DownloadCompletionThread was interrupted");
|
||||||
|
return;
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
Log.e(TAG, "ExecutionException in DownloadCompletionThread: " + e.getMessage());
|
Log.e(TAG, "ExecutionException in DownloadCompletionThread: " + e.getMessage());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.d(TAG, "End of downloadCompletionThread");
|
Log.d(TAG, "End of downloadCompletionThread");
|
||||||
|
|
Loading…
Reference in New Issue