Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support throw non-RuntimeException in the callback method: FileDownloadList#blockCompleted #369

Closed
wangsuicheng opened this issue Oct 18, 2016 · 3 comments

Comments

@wangsuicheng
Copy link

想问下,如果支持的话,需要怎么配置?谢谢~~

@Jacksgong
Copy link
Collaborator

恩。可以在 FileDownloadListener#blockCompleted的地方直接做 md5 校验(我们自己也是这样做),如果校验失败了直接抛一个Exception:

  1. blockCompleted 就是在独立线程中执行的
  2. blockCompleted 回调的时候已经下载完成
  3. blockCompleted中抛Exception会自动回调到error中。

我们自己的项目中也是在blockCompleted中校验的。

@wangsuicheng
Copy link
Author

wangsuicheng commented Oct 18, 2016

意思就是说如果在blockCompleted中抛出异常,就走error不走Completed这个回调了吧?
我在blockCompleted中写一些容易抛出异常的方法,要提示我捕获异常try catch,不写的话就是报错的

@Jacksgong
Copy link
Collaborator

Jacksgong commented Oct 18, 2016

意思就是说如果在blockCompleted中抛出异常,就走error不走Completed这个回调了吧?

是的。


如果抛出的异常非RuntimeException或其子类的Exception的话,是需要强制处理的。在3.0版本中我会对这个支持。


目前版本(1.2.2)的解决方案: 你捕捉到以后将其转为 RuntimeException或其子类的Exception抛出即可。

@Jacksgong Jacksgong added this to the 1.3.0 milestone Oct 18, 2016
@Jacksgong Jacksgong changed the title FileDownloader支持做md5全文校验吗? Support throw non-RuntimeException in the callback method: FileDownloadList#blockCompleted Oct 18, 2016
Jacksgong added a commit that referenced this issue Oct 19, 2016
…ept any exception, and remove the FileDownloadListener#callback method, beside add the FileDownloadListener#isInvalid method to tell the FileDownloader whether the listener has already invalidated, which means it can't receive any messages

Closes #369
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants