Open hellozengms opened 5 years ago
你有没有给你的每个任务设置 path ?或者 filename ? 直接出示一下你如果初始化你的多个 Task 的?
final List<BaseDownloadTask> tasks = new ArrayList<>();
FileDownloadQueueSet queueSet = new FileDownloadQueueSet(new FileDownloadListener() {
@Override
protected void pending(BaseDownloadTask task, int soFarBytes, int totalBytes) {
}
@Override
protected void progress(BaseDownloadTask task, int soFarBytes, int totalBytes) {
}
@Override
protected void completed(BaseDownloadTask task) {
}
@Override
protected void paused(BaseDownloadTask task, int soFarBytes, int totalBytes) {
}
@Override
protected void error(BaseDownloadTask task, Throwable e) {
}
@Override
protected void warn(BaseDownloadTask task) {
}
});
for (String url : urls) {
tasks.add(FileDownloader.getImpl().create(url)
.setTag(url).setPath(dirPath, true));
}
queueSet.disableCallbackProgressTimes();
queueSet.setSyncCallback(isSync);
queueSet.setAutoRetryTimes(3);
queueSet.setForceReDownload(true);
// 并行下载
queueSet.downloadTogether(tasks);
queueSet.start();
你的 dirPath
有没有可能为空?
这个问题,我能复现的,使用一个无法访问会返回404的链接,传递路径使用setPath(dirPath, true)
,就会出现空指针异常
java.lang.NullPointerException
解析原始 1 java.io.File.(File.java:262)
2 com.liulishuo.filedownloader.download.DownloadStatusCallback.void renameTempFile()(DownloadStatusCallback.java:294)
3 com.liulishuo.filedownloader.download.DownloadStatusCallback.void handleCompleted()(DownloadStatusCallback.java:381)
4 com.liulishuo.filedownloader.download.DownloadStatusCallback.void onCompletedDirectly()(DownloadStatusCallback.java:197)
5 com.liulishuo.filedownloader.download.DownloadLaunchRunnable.void run()(DownloadLaunchRunnable.java:336)
6 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
7 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
8 java.lang.Thread.run(Thread.java:761)