From 4530413d97e080a6dde2d16a57a7d5499e18f895 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Tue, 10 Dec 2019 22:05:57 +0100 Subject: 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. --- .../de/danoeh/antennapod/core/service/download/DownloadService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java index 0528fc3dc..04c1190a7 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java @@ -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"); -- cgit v1.2.3