Return a copy of the downloads.
This should prevent any IndexOutOfBounds errors fixes AntennaPod/AntennaPod#968
This commit is contained in:
parent
e332df4af5
commit
d4fb1b0968
|
@ -243,7 +243,7 @@ public class DownloadService extends Service {
|
|||
handler = new Handler();
|
||||
newMediaFiles = Collections.synchronizedList(new ArrayList<Long>());
|
||||
reportQueue = Collections.synchronizedList(new ArrayList<DownloadStatus>());
|
||||
downloads = new ArrayList<Downloader>();
|
||||
downloads = Collections.synchronizedList(new ArrayList<Downloader>());
|
||||
numberOfDownloads = new AtomicInteger(0);
|
||||
|
||||
IntentFilter cancelDownloadReceiverFilter = new IntentFilter();
|
||||
|
@ -1246,7 +1246,10 @@ public class DownloadService extends Service {
|
|||
}
|
||||
|
||||
public List<Downloader> getDownloads() {
|
||||
return downloads;
|
||||
// return a copy of downloads, but the copy doesn't need to be synchronized.
|
||||
synchronized (downloads) {
|
||||
return new ArrayList<Downloader>(downloads);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue