{"record":{"id":"f8bc73bb298209a0","repo":"lingochamp/FileDownloader","slug":"can-t-handover-the-message-no-master-to-receive-t","errorCode":null,"errorMessage":"can't handover the message, no master to receive this message(status[%d]) size[%d]","messagePattern":"can't handover the message, no master to receive this message\\(status\\[(.+?)\\]\\) size\\[(.+?)\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/liulishuo/filedownloader/FileDownloadMessenger.java","lineNumber":254,"sourceCode":"                                + \" parcel queue[%d] queue-top-status[%d]\",\n                        this, queueTopTask.getId(), parcelQueue.size(), queueTopTask.getStatus());\n            }\n            mTask = null;\n        }\n    }\n\n    @Override\n    public void handoverMessage() {\n        if (mIsDiscard) {\n            return;\n        }\n\n        final MessageSnapshot message = parcelQueue.poll();\n        final int currentStatus = message.getStatus();\n        final BaseDownloadTask.IRunningTask task = mTask;\n\n        if (task == null) {\n            throw new IllegalArgumentException(FileDownloadUtils.formatString(\n                    \"can't handover the message, no master to receive this \"\n                            + \"message(status[%d]) size[%d]\",\n                    currentStatus, parcelQueue.size()));\n        }\n\n        final BaseDownloadTask originTask = task.getOrigin();\n\n        final FileDownloadListener listener = originTask.getListener();\n        final ITaskHunter.IMessageHandler messageHandler = task.getMessageHandler();\n\n        inspectAndHandleOverStatus(currentStatus);\n\n        if (listener == null || listener.isInvalid()) {\n            return;\n        }\n\n        if (currentStatus == FileDownloadStatus.blockComplete) {\n            try {","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/lingochamp/FileDownloader/blob/6237a8cac174bcc916e4342b14ab1ab72a5768d4/library/src/main/java/com/liulishuo/filedownloader/FileDownloadMessenger.java#L236-L272","documentation":"FileDownloadMessenger.handoverMessage() throws IllegalArgumentException when a status message snapshot arrives but mTask is null — no task master is attached to receive it. This indicates the messenger was already released/cleared while a queued message was still being processed, i.e. an internal lifecycle race or misuse of the task's lifecycle.","triggerScenarios":"Delivering a message snapshot after the task was detached/released (task finished and recycled), or calling internal lifecycle methods after dispose.","commonSituations":"Listener callbacks arriving after cancel/pause and release; aggressive task recycling; interacting with the task object from multiple threads after completion.","solutions":["Do not touch the task or its callback after it finishes/is cancelled; drop references once complete() or the listener's final callback fires.","Avoid calling reuse()/starting a released task; create a new task.","Keep operations on the task on a single thread; this is usually a library-internal race — update FileDownloader to the latest version where the race is fixed.","Guard your listener callbacks to ignore callbacks after your own lifecycle considers the task done."],"exampleFix":"// before\n@Override public void warnOnMobile(BaseDownloadTask task, int sofar, int totalBytes) {\n    pausedTask.start();\n}\n\n// after\n@Override public void warnOnMobile(BaseDownloadTask task, int sofar, int totalBytes) {\n    if (!isTaskActive(task)) return;\n    task.reuse();\n    task.start();\n}","handlingStrategy":"try-catch","validationCode":"if (task.getStatus() != FileDownloadStatus.progress) return; // task may already be released","typeGuard":null,"tryCatchPattern":"try { messengerDispatch(); } catch (IllegalArgumentException e) { Log.w(TAG, \"message after release, ignored\", e); }","preventionTips":["Stop touching task objects after their terminal callback (completed/error/paused).","Avoid reusing a task object across threads after finishing.","Keep the library updated; this is largely an internal race.","Clear pending handler callbacks before releasing a task."],"tags":["android","lifecycle-race","internal-state"],"backgroundTag":"internal-invariant-violation","analyzedSha":"6237a8cac174bcc916e4342b14ab1ab72a5768d4","analyzedAt":"2026-09-08T23:50:48.168Z","contentChangedAt":"2026-09-08T23:50:48.168Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}