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:
ByteHamster 2019-12-10 22:05:57 +01:00
parent a99a41e3bb
commit 4530413d97
1 changed files with 2 additions and 1 deletions

View File

@ -260,7 +260,6 @@ public class DownloadService extends Service {
removeDownload(downloader);
numberOfDownloads.decrementAndGet();
queryDownloadsAsync();
});
} else {
handleFailedDownload(downloader);
@ -270,8 +269,10 @@ public class DownloadService extends Service {
}
} catch (InterruptedException e) {
Log.e(TAG, "DownloadCompletionThread was interrupted");
return;
} catch (ExecutionException e) {
Log.e(TAG, "ExecutionException in DownloadCompletionThread: " + e.getMessage());
return;
}
}
Log.d(TAG, "End of downloadCompletionThread");