diff options
author | ByteHamster <info@bytehamster.com> | 2020-01-03 22:50:27 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2020-01-03 22:50:30 +0100 |
commit | 3e8c1ee11761b012bfd61c954ba4957cdd942122 (patch) | |
tree | d62e1483fd89c7f3765456ebcc516eab8b68d2dc /core | |
parent | 29a8a5e5aaa278b1f039f3a9f116aba3a51ddc49 (diff) | |
download | AntennaPod-3e8c1ee11761b012bfd61c954ba4957cdd942122.zip |
Only modify and query downloads array in main thread
This fixes a ConcurrentModificationException if the thread that queues downloads (database IO)
adds the item to the downloads list and the notification updater queries the downloads list at
the same time.
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java | 12 |
1 files changed, 6 insertions, 6 deletions
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 0be96d398..f7c338729 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 @@ -477,13 +477,13 @@ public class DownloadService extends Service { && isEnqueued(request, itemsEnqueued)) { request.setMediaEnqueued(true); } - downloads.add(downloader); - downloadExecutor.submit(downloader); - - postDownloaders(); + handler.post(() -> { + downloads.add(downloader); + downloadExecutor.submit(downloader); + postDownloaders(); + }); } - - queryDownloads(); + handler.post(this::queryDownloads); } private static boolean isEnqueued(@NonNull DownloadRequest request, |