lingochamp/FileDownloader · error · IllegalStateException
the messenger is working, can't re-appointment for
Error message
the messenger is working, can't re-appointment for %s
What it means
FileDownloadMessenger.reAppointment() throws IllegalStateException if the messenger already has a task (mTask != null); a messenger instance can only be assigned to one running task at a time. Re-appointing without first releasing the previous assignment is an invalid lifecycle transition.
Solutions
- Create a new messenger (or call its dispose/release first) before reAppointment.
- Assign one messenger per task; do not share messenger objects between tasks.
- Use the standard FileDownloader.create flow, which allocates a fresh messenger per task.
Example fix
// before messenger.reAppointment(taskA); messenger.reAppointment(taskB); // after messenger.reAppointment(taskA); messenger.dispose(); messenger.reAppointment(taskB);
Defensive patterns
Strategy: validation
Validate before calling
if (messenger.hasTask()) messenger.dispose(); messenger.reAppointment(task, callback);
Try / catch
try { messenger.reAppointment(task, cb); } catch (IllegalStateException e) { messenger.dispose(); messenger.reAppointment(task, cb); } Prevention
- One messenger per task; never share across tasks.
- Always dispose/release before re-appointment.
- Use FileDownloader.create instead of hand-building messengers.
When it happens
Trigger: Reusing a single FileDownloadMessenger (or the same running-task wrapper) across multiple tasks without clearing it, or calling reAppointment twice.
Common situations: Custom task pool implementations sharing a messenger; manually constructed IRunningTask wrappers in tests or advanced usage.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- This task is dirty to restart, If you want to reuse this…
- If you start the task manually, it means this task doesn't…
- This task is running
- the provided mPath[ ] is invalid, can't find its directory
- Create parent directory failed, please make sure you have…
AI-assisted analysis of lingochamp/FileDownloader@6237a8cac1 (2026-09-08).
Data as JSON: /api/errors/22bcf585caab71c0.
Report an issue: GitHub.
Appendix: source
Thrown at library/src/main/java/com/liulishuo/filedownloader/FileDownloadMessenger.java:380
// already same url & path in pending/running list
listener.warn(originTask);
break;
default:
// ignored
}
}
}
@Override
public boolean handoverDirectly() {
return mTask.getOrigin().isSyncCallback();
}
@Override
public void reAppointment(BaseDownloadTask.IRunningTask task,
BaseDownloadTask.LifeCycleCallback callback) {
if (this.mTask != null) {
throw new IllegalStateException(
FileDownloadUtils.formatString("the messenger is working, can't "
+ "re-appointment for %s", task));
}
init(task, callback);
}
@Override
public boolean isBlockingCompleted() {
return parcelQueue.peek().getStatus() == FileDownloadStatus.blockComplete;
}
@Override
public void discard() {
mIsDiscard = true;
}
@OverrideView on GitHub (pinned to 6237a8cac1)