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.
This commit is contained in:
parent
29a8a5e5aa
commit
3e8c1ee117
|
@ -477,13 +477,13 @@ public class DownloadService extends Service {
|
||||||
&& isEnqueued(request, itemsEnqueued)) {
|
&& isEnqueued(request, itemsEnqueued)) {
|
||||||
request.setMediaEnqueued(true);
|
request.setMediaEnqueued(true);
|
||||||
}
|
}
|
||||||
|
handler.post(() -> {
|
||||||
downloads.add(downloader);
|
downloads.add(downloader);
|
||||||
downloadExecutor.submit(downloader);
|
downloadExecutor.submit(downloader);
|
||||||
|
|
||||||
postDownloaders();
|
postDownloaders();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
handler.post(this::queryDownloads);
|
||||||
queryDownloads();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isEnqueued(@NonNull DownloadRequest request,
|
private static boolean isEnqueued(@NonNull DownloadRequest request,
|
||||||
|
|
Loading…
Reference in New Issue