You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
try {
...
if (file.exists() && file.isFile()) {
// it have already provided file for it.thrownewIllegalArgumentException("If you want filename from "
+ "response please make sure you provide path is directory " + file.getPath());
}
...
} finally {
this.id = OkDownload.with().breakpointStore().findOrCreateId(this);
}
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxx.sample.webdownloader, PID: 16251
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.liulishuo.okdownload.core.download.DownloadStrategy$FilenameHolder.get()' on a null object reference
at com.liulishuo.okdownload.DownloadTask.getFilename(DownloadTask.java:230)
at com.liulishuo.okdownload.core.breakpoint.KeyToIdMap.generateKey(KeyToIdMap.java:63)
at com.liulishuo.okdownload.core.breakpoint.KeyToIdMap.get(KeyToIdMap.java:43)
at com.liulishuo.okdownload.core.breakpoint.BreakpointStoreOnCache.findOrCreateId(BreakpointStoreOnCache.java:146)
at com.liulishuo.okdownload.core.breakpoint.BreakpointStoreOnSQLite.findOrCreateId(BreakpointStoreOnSQLite.java:100)
at com.liulishuo.okdownload.DownloadTask.<init>(DownloadTask.java:190)
at com.liulishuo.okdownload.DownloadTask$Builder.build(DownloadTask.java:838)
从而掩盖了 throw new IllegalArgumentException("If you want filename from " + "response please make sure you provide path is directory " + file.getPath());
的异常信息。
导致追查问题时不方便。
The text was updated successfully, but these errors were encountered:
AzureFatty
changed the title
异常处理不太合理
DownloadTask 路径是文件,而不是文件夹情况下的异常处理设计不太合理
Apr 24, 2018
AzureFatty
changed the title
DownloadTask 路径是文件,而不是文件夹情况下的异常处理设计不太合理
目标存储路径是文件,而不是文件夹情况下的异常处理设计不太合理
Apr 24, 2018
在
DownloadTask.java
中此处判断
file.exists() && file.isFile()
抛出IllegalArgumentException
异常,当此判断条件成立时,因为加了finally,所以代码还会执行
this.id = OkDownload.with().breakpointStore().findOrCreateId(this);
而此时会抛出
从而掩盖了
throw new IllegalArgumentException("If you want filename from " + "response please make sure you provide path is directory " + file.getPath());
的异常信息。
导致追查问题时不方便。
The text was updated successfully, but these errors were encountered: