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

NullPointerException in com.amaze.filemanager.filesystem.FileUtil.deleteFilesInFolder #1102

Closed
ape-report opened this Issue Mar 10, 2018 · 0 comments

Comments

Projects
None yet
3 participants
@ape-report

ape-report commented Mar 10, 2018

Reproduce

  1. Delete a folder that requires root in an unrooted phone, e.g., /acct.

Cause:

According to https://developer.android.com/reference/java/io/File.html#listFiles(),
method listFiles may return null if I/O errors happen.

// java.lang.RuntimeException: An error occurred while executing doInBackground()
// 	at android.os.AsyncTask$3.done(AsyncTask.java:309)
// 	at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
// 	at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
// 	at java.util.concurrent.FutureTask.run(FutureTask.java:242)
// 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
// 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
// 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
// 	at java.lang.Thread.run(Thread.java:818)
// Caused by: java.lang.NullPointerException: Attempt to get length of null array
// 	at com.amaze.filemanager.filesystem.FileUtil.deleteFilesInFolder(FileUtil.java:604)
// 	at com.amaze.filemanager.filesystem.FileUtil.deleteFile(FileUtil.java:315)
// 	at com.amaze.filemanager.filesystem.HFile.delete(HFile.java:1028)
// 	at com.amaze.filemanager.services.DeleteTask.doInBackground(DeleteTask.java:132)
// 	at com.amaze.filemanager.services.DeleteTask.doInBackground(DeleteTask.java:48)
// 	at android.os.AsyncTask$2.call(AsyncTask.java:295)
// 	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
// 	... 4 more

@EmmanuelMess EmmanuelMess added the bug label Mar 10, 2018

@EmmanuelMess EmmanuelMess added this to the v3.3.0 milestone Mar 10, 2018

@TranceLove TranceLove self-assigned this Mar 20, 2018

TranceLove added a commit to TranceLove/AmazeFileManager that referenced this issue Mar 20, 2018

Fix NullPointerException thrown on deleting folders outside storage
Fixes TeamAmaze#1102. Deleting folders outside storage area is still not possible (either with or without root) after this change, but you'll get an error Toast instead of an app crash.

- Code cleanups at FileUtil: remove rmdir1() and deleteFilesInFolder()
- Fix FileUtil.rmdir()
- Fix DeleteTask, display error Toast on problem during deleting folder

TranceLove added a commit to TranceLove/AmazeFileManager that referenced this issue Mar 20, 2018

Fix NullPointerException thrown on deleting folders outside storage
Fixes TeamAmaze#1102. Deleting folders outside storage area is still not possible (either with or without root) after this change, but you'll get an error Toast instead of an app crash.

- Code cleanups at FileUtil: remove rmdir1() and deleteFilesInFolder()
- Fix FileUtil.rmdir()
- Fix DeleteTask, display error Toast on problem during deleting folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment