lingochamp/FileDownloader · error · IllegalArgumentException

can't handover the message, no master to receive this…

Error message

can't handover the message, no master to receive this message(status[%d]) size[%d]

What it means

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.

Solutions

  1. Do not touch the task or its callback after it finishes/is cancelled; drop references once complete() or the listener's final callback fires.
  2. Avoid calling reuse()/starting a released task; create a new task.
  3. 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.
  4. Guard your listener callbacks to ignore callbacks after your own lifecycle considers the task done.

Example fix

// before
@Override public void warnOnMobile(BaseDownloadTask task, int sofar, int totalBytes) {
    pausedTask.start();
}

// after
@Override public void warnOnMobile(BaseDownloadTask task, int sofar, int totalBytes) {
    if (!isTaskActive(task)) return;
    task.reuse();
    task.start();
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (task.getStatus() != FileDownloadStatus.progress) return; // task may already be released

Try / catch

try { messengerDispatch(); } catch (IllegalArgumentException e) { Log.w(TAG, "message after release, ignored", e); }

Prevention

When it happens

Trigger: Delivering a message snapshot after the task was detached/released (task finished and recycled), or calling internal lifecycle methods after dispose.

Common situations: Listener callbacks arriving after cancel/pause and release; aggressive task recycling; interacting with the task object from multiple threads after completion.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of lingochamp/FileDownloader@6237a8cac1 (2026-09-08). Data as JSON: /api/errors/f8bc73bb298209a0. Report an issue: GitHub.

Appendix: source

Thrown at library/src/main/java/com/liulishuo/filedownloader/FileDownloadMessenger.java:254

                                + " parcel queue[%d] queue-top-status[%d]",
                        this, queueTopTask.getId(), parcelQueue.size(), queueTopTask.getStatus());
            }
            mTask = null;
        }
    }

    @Override
    public void handoverMessage() {
        if (mIsDiscard) {
            return;
        }

        final MessageSnapshot message = parcelQueue.poll();
        final int currentStatus = message.getStatus();
        final BaseDownloadTask.IRunningTask task = mTask;

        if (task == null) {
            throw new IllegalArgumentException(FileDownloadUtils.formatString(
                    "can't handover the message, no master to receive this "
                            + "message(status[%d]) size[%d]",
                    currentStatus, parcelQueue.size()));
        }

        final BaseDownloadTask originTask = task.getOrigin();

        final FileDownloadListener listener = originTask.getListener();
        final ITaskHunter.IMessageHandler messageHandler = task.getMessageHandler();

        inspectAndHandleOverStatus(currentStatus);

        if (listener == null || listener.isInvalid()) {
            return;
        }

        if (currentStatus == FileDownloadStatus.blockComplete) {
            try {

View on GitHub (pinned to 6237a8cac1)