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

java.lang.IllegalArgumentException:at DownloadStatusCallback.java:96 #612

Closed
chiemy opened this issue Jun 16, 2017 · 1 comment
Closed
Labels
Milestone

Comments

@chiemy
Copy link

chiemy commented Jun 16, 2017

if (oldEtag != null && !oldEtag.equals(etag)) throw new IllegalArgumentException();

etag 是什么?怎么避免此异常?

@Jacksgong
Copy link
Collaborator

Etag是断点续传的前置条件,如果有变更说明远端资源变化,此时便不应该断点续传而是从头开始下载。具体可以参看这里: HTTP ETag.


我根据FileDownloader 1.5.5,以及你提供的DownloadStatusCallback.java:96定位到这个问题。

为什么抛这个异常?

这里的代码逻辑上下文是需要确保是一个正确的断点续传,或正确的开始获取数据,防止随后数据获取与本地资源数据不匹配的问题。

这个异常是怎么遇到的?

其实如果是合法的HTTP返回是不会有这个问题的,因为在遇到这个问题之前,已经对远端数据更改进行来处理。

但是如果是非法HTTP返回应该会可能遇到这个问题,具体情况是:

  1. 断点续传时请求带上来上一次的返回的Etag
  2. 返回来的Response是206,说明是上次的Etag是有效的,支持从断点除下载
  3. 但是返回的Etag却和请求头带上的Etag却不同,这里与返回状态值206矛盾了,这种情况如果Etag变更,说明资源变更,不应该返回206,而是返回412或200。

怎么解决这个问题?

该问题会在新版本中修复。

  1. 1.5.5版本中并没有处理412,而是处理了etag变更并且返回是200的情况,这个问题新版本会修复
  2. 新版本会处理etag变更,并且返回200的情况,但是会输出一个Warn的Logcat

@Jacksgong Jacksgong added the bug label Jun 16, 2017
@Jacksgong Jacksgong added this to the 1.5.6 milestone Jun 16, 2017
Jacksgong added a commit that referenced this issue Jun 16, 2017
…and its etag is changed and handle 416 case\nCloses #612
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants