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

Crash #961

Closed
Jeffin21 opened this issue Mar 7, 2018 · 20 comments
Closed

Crash #961

Jeffin21 opened this issue Mar 7, 2018 · 20 comments
Labels

Comments

@Jeffin21
Copy link

Jeffin21 commented Mar 7, 2018

java.lang.NullPointerException:
at java.io.File.fixSlashes (File.java:185)
at java.io.File. (File.java:134)
at com.liulishuo.filedownloader.download.DownloadRunnable.run (DownloadRunnable.java:121)
at com.liulishuo.filedownloader.download.DownloadLaunchRunnable.realDownloadWithSingleConnection (DownloadLaunchRunnable.java:593)
at com.liulishuo.filedownloader.download.DownloadLaunchRunnable.run (DownloadLaunchRunnable.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:587)
at java.lang.Thread.run (Thread.java:818)

@Jacksgong
Copy link
Collaborator

@Jeffin21 可否告知下版本号?

@Jeffin21
Copy link
Author

Jeffin21 commented Mar 7, 2018

latest version

@Jeffin21
Copy link
Author

Jeffin21 commented Mar 7, 2018

v1.7.1

@Jacksgong
Copy link
Collaborator

@Jeffin21 可否告知下具体哪个版本的Android系统,我查下File的源码,这个问题比较奇怪。

@Jeffin21
Copy link
Author

Jeffin21 commented Mar 7, 2018

Samsung Galaxy J2 (2018) (j2y18lte), 1536MB RAM, Android 7.1

@Jeffin21
Copy link
Author

Jeffin21 commented Mar 7, 2018

i added codes for this #949 issue by @rantianhua

@Jeffin21
Copy link
Author

Jeffin21 commented Mar 7, 2018

5646236 e45ffa5

@Jacksgong
Copy link
Collaborator

@Jeffin21 thanks for your issue, but this crash is different with #949 . It seems that something wrong on File.java, which has been discussed on here .

@Jeffin21
Copy link
Author

Jeffin21 commented Mar 7, 2018

it happens on 7.0 and above

@Jeffin21
Copy link
Author

Jeffin21 commented Mar 7, 2018

this crash happens in so many above 7.0 devices , i only gave one device sample to you

@Jacksgong
Copy link
Collaborator

@Jeffin21 Okay, thanks, I test FileDownloader sample project on devices 8.0.0 can't reproduce such crash, and check the source code(only match 4.2.2 source code, 7.1.0 or 7.0 didn't provide File.java source, and 6.0 source can't match 185 line number you provide), and on the 4.2.2 source code indicate only if we provide null on File constructor such as new File(null) can produce such problem. But DownloadRunnable.java(121) you provide can't match any possible line number on v1.7.1.

@Jeffin21
Copy link
Author

Jeffin21 commented Mar 7, 2018

I'll check and let you know about this later. Thank You

@Jacksgong
Copy link
Collaborator

@Jeffin21 so, could you please provide the real code on DownloadRunnable.java:121? you can decompile your apk to find it, or find it by real dependency code in your project.

@Jeffin21
Copy link
Author

Jeffin21 commented Mar 7, 2018

FileDownloadDatabase database = CustomComponentHolder.getImpl().getDatabaseInstance();
database.updateConnectionCount(downloadId, 1);
new File(path).delete();

@Jacksgong this code in that place

@Jacksgong
Copy link
Collaborator

Jacksgong commented Mar 7, 2018

so... you change the code? I don't think the following logic is the originDownloadRunnable.java does:

 /*  throw new SocketException(FileDownloadUtils.
         formatString(
                 "Connection failed with request[%s] response[%s] "
                         + "http-state[%d] on task[%d-%d], which is changed"
                         + " after verify connection, so please try again.",
                 connectTask.getRequestHeader(),
                 connection.getResponseHeaderFields(),
                 code, downloadId, connectionIndex));*/

 //FileDownloader.getImpl().pause(downloadId);
 TasksManagerDBController task = new TasksManagerDBController();
 TasksManagerModel model = task.getItemByID(String.valueOf(downloadId));
 String path = model.getPath();

 if(PreferenceHelper.getToastMsgService(GDMApplication._appContext,downloadId)==0) {
     System.out.println("download runnable:");
     PreferenceHelper.setToastMsgService(GDMApplication._appContext, 1, downloadId);
 }

 FileDownloadDatabase database = CustomComponentHolder.getImpl().getDatabaseInstance();
 database.updateConnectionCount(downloadId, 1);
 new File(path).delete();

@Jeffin21
Copy link
Author

Jeffin21 commented Mar 7, 2018

Yes , i changed the code. i told you before need a feature. Some URLs like dailymotion video they dont support multidownload the only way to download that files is to 1st check multi threading is supported if not it go to give upretry expection and we again try to download with single thread and it workds we made some changes for our need

@Jacksgong
Copy link
Collaborator

  • First of all, on here, because of codes changed I don't know why model.getPath() is null on here, you please finger out by yourself.
  • Secondly, I have already told you the solution and cause, and the worst plan is if the download failed on the first time for the task, just change the connection count for it by ConnectionCountAdapter, you can do such things very clean.

finally, if you think the solution you provide is nice the PR is very welcome.

@Jeffin21
Copy link
Author

Jeffin21 commented Mar 7, 2018

we did with ConnectionCountAdapter and that wont work in our case

@Jacksgong
Copy link
Collaborator

Jacksgong commented Mar 7, 2018

@Jeffin21 If the second time it doesn't invoke ConectionCountAdapter to judge the connection count, you can invoke FileDownloader#clear(id, path) to clear data of it on error callback scope.

@Jeffin21
Copy link
Author

Jeffin21 commented Mar 7, 2018

Let me try it . Thanks

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