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)) {
|
||||
request.setMediaEnqueued(true);
|
||||
}
|
||||
handler.post(() -> {
|
||||
downloads.add(downloader);
|
||||
downloadExecutor.submit(downloader);
|
||||
|
||||
postDownloaders();
|
||||
});
|
||||
}
|
||||
|
||||
queryDownloads();
|
||||
handler.post(this::queryDownloads);
|
||||
}
|
||||
|
||||
private static boolean isEnqueued(@NonNull DownloadRequest request,
|
||||
|
|
Loading…
Reference in New Issue