Open zhijianfree opened 5 years ago
我觉得还是代码问题,根据堆栈信息看到如下代码
// fetch
int fetchLength = inputStream.read(readBuffer);
if (fetchLength == -1) {
return fetchLength;
}
我想如果直接写入文件是没问题的,读取到内存 再写入文件 中间就出问题了
还是贴一下我这边出现的堆栈吧,实在是太频繁了
2018-12-26 14:01:51.263 26082-26082/cn.findpiano.piano.dev E/FindDownloadModule: java.net.ProtocolException: unexpected end of stream
at okhttp3.internal.http1.Http1Codec$FixedLengthSource.read(Http1Codec.java:409)
at okio.RealBufferedSource$1.read(RealBufferedSource.java:440)
at java.io.InputStream.read(InputStream.java:101)
at com.liulishuo.okdownload.core.interceptor.FetchDataInterceptor.interceptFetch(FetchDataInterceptor.java:62)
at com.liulishuo.okdownload.core.download.DownloadChain.processFetch(DownloadChain.java:220)
at com.liulishuo.okdownload.core.download.DownloadChain.loopFetch(DownloadChain.java:228)
at com.liulishuo.okdownload.core.interceptor.BreakpointInterceptor.interceptFetch(BreakpointInterceptor.java:108)
at com.liulishuo.okdownload.core.download.DownloadChain.processFetch(DownloadChain.java:220)
at com.liulishuo.okdownload.core.interceptor.RetryInterceptor.interceptFetch(RetryInterceptor.java:57)
at com.liulishuo.okdownload.core.download.DownloadChain.processFetch(DownloadChain.java:220)
at com.liulishuo.okdownload.core.download.DownloadChain.start(DownloadChain.java:195)
at com.liulishuo.okdownload.core.download.DownloadChain.run(DownloadChain.java:247)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
我下载https的图片一直没成功过,回调的进度方法也不执行,直接taskend!
我觉得还是代码问题,根据堆栈信息看到如下代码
// fetch int fetchLength = inputStream.read(readBuffer); if (fetchLength == -1) { return fetchLength; }
我想如果直接写入文件是没问题的,读取到内存 再写入文件 中间就出问题了
还是贴一下我这边出现的堆栈吧,实在是太频繁了
2018-12-26 14:01:51.263 26082-26082/cn.findpiano.piano.dev E/FindDownloadModule: java.net.ProtocolException: unexpected end of stream at okhttp3.internal.http1.Http1Codec$FixedLengthSource.read(Http1Codec.java:409) at okio.RealBufferedSource$1.read(RealBufferedSource.java:440) at java.io.InputStream.read(InputStream.java:101) at com.liulishuo.okdownload.core.interceptor.FetchDataInterceptor.interceptFetch(FetchDataInterceptor.java:62) at com.liulishuo.okdownload.core.download.DownloadChain.processFetch(DownloadChain.java:220) at com.liulishuo.okdownload.core.download.DownloadChain.loopFetch(DownloadChain.java:228) at com.liulishuo.okdownload.core.interceptor.BreakpointInterceptor.interceptFetch(BreakpointInterceptor.java:108) at com.liulishuo.okdownload.core.download.DownloadChain.processFetch(DownloadChain.java:220) at com.liulishuo.okdownload.core.interceptor.RetryInterceptor.interceptFetch(RetryInterceptor.java:57) at com.liulishuo.okdownload.core.download.DownloadChain.processFetch(DownloadChain.java:220) at com.liulishuo.okdownload.core.download.DownloadChain.start(DownloadChain.java:195) at com.liulishuo.okdownload.core.download.DownloadChain.run(DownloadChain.java:247) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)
解决了吗大佬,unexpected end of stream 究竟是啥问题呀
OkDownload Version
v1.0.4-SNAPSHOT