TeamAmaze / TeamAmaze/AmazeFileManager

NPE on `HybridFile#length`

Open
#4,004 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Crash-NullPointerException From-telegram Issue-Easy (good first issue)
Dominant language
Kotlin
Stars
6.4k
Forks
1.7k
Avg merge
3d 9h
Merged PRs (30d)
1

Description

Issue explanation (write below this line)

Exception

  • App Name: Amaze File Manager
  • Package: com.amaze.filemanager
  • Version: 3.8.5
  • User Action: UI Error
  • Request: Application crash
  • OS: Linux Android 13 - 33
  • Device: a34x
  • Model: SM-A346E
  • Product: a34xdxx
Crash log

java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$4.done(AsyncTask.java:415)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:381)
at java.util.concurrent.FutureTask.setException(FutureTask.java:250)
at java.util.concurrent.FutureTask.run(FutureTask.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'long androidx.documentfile.provider.DocumentFile.length()' on a null object reference
at com.amaze.filemanager.filesystem.HybridFile.length(HybridFile.java:391)
at com.amaze.filemanager.filesystem.files.FileUtils.getBaseFileSize(FileUtils.java:216)
at com.amaze.filemanager.filesystem.HybridFile.lambda$folderSize$5(HybridFile.java:758)
at com.amaze.filemanager.filesystem.HybridFile.$r8$lambda$WzIrBMaWCmenL3KN0t4m2j8r6Ms(Unknown Source:0)
at com.amaze.filemanager.filesystem.HybridFile$$ExternalSyntheticLambda1.onFileFound(Unknown Source:4)
at com.amaze.filemanager.utils.OTGUtil.getDocumentFiles(OTGUtil.kt:139)
at com.amaze.filemanager.filesystem.HybridFile.folderSize(HybridFile.java:753)
at com.amaze.filemanager.filesystem.files.FileUtils.getBaseFileSize(FileUtils.java:214)
at com.amaze.filemanager.filesystem.files.FileUtils.getTotalBytes(FileUtils.java:207)
at com.amaze.filemanager.asynchronous.asynctasks.movecopy.PrepareCopyTask.doInBackground(PrepareCopyTask.java:147)
at com.amaze.filemanager.asynchronous.asynctasks.movecopy.PrepareCopyTask.doInBackground(PrepareCopyTask.java:68)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
... 3 more


Reporter: None

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in com/amaze/filemanager/filesystem/HybridFile.java at length() line 391 and trace how DocumentFile is obtained. Read the callers in FileUtils.java and the folderSize path, then check how PrepareCopyTask.java reaches total size calculation. Done means the reported copy-preparation path no longer crashes with this null DocumentFile case.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java, kotlin
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.