{"record":{"id":"22bcf585caab71c0","repo":"lingochamp/FileDownloader","slug":"the-messenger-is-working-can-t-re-appointment-for","errorCode":null,"errorMessage":"the messenger is working, can't re-appointment for %s","messagePattern":"the messenger is working, can't re-appointment for (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/liulishuo/filedownloader/FileDownloadMessenger.java","lineNumber":380,"sourceCode":"                    // already same url & path in pending/running list\n                    listener.warn(originTask);\n                    break;\n                default:\n                    // ignored\n            }\n        }\n    }\n\n    @Override\n    public boolean handoverDirectly() {\n        return mTask.getOrigin().isSyncCallback();\n    }\n\n    @Override\n    public void reAppointment(BaseDownloadTask.IRunningTask task,\n                              BaseDownloadTask.LifeCycleCallback callback) {\n        if (this.mTask != null) {\n            throw new IllegalStateException(\n                    FileDownloadUtils.formatString(\"the messenger is working, can't \"\n                            + \"re-appointment for %s\", task));\n        }\n\n        init(task, callback);\n    }\n\n    @Override\n    public boolean isBlockingCompleted() {\n        return parcelQueue.peek().getStatus() == FileDownloadStatus.blockComplete;\n    }\n\n    @Override\n    public void discard() {\n        mIsDiscard = true;\n    }\n\n    @Override","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/lingochamp/FileDownloader/blob/6237a8cac174bcc916e4342b14ab1ab72a5768d4/library/src/main/java/com/liulishuo/filedownloader/FileDownloadMessenger.java#L362-L398","documentation":"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.","triggerScenarios":"Reusing a single FileDownloadMessenger (or the same running-task wrapper) across multiple tasks without clearing it, or calling reAppointment twice.","commonSituations":"Custom task pool implementations sharing a messenger; manually constructed IRunningTask wrappers in tests or advanced usage.","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."],"exampleFix":"// before\nmessenger.reAppointment(taskA);\nmessenger.reAppointment(taskB);\n\n// after\nmessenger.reAppointment(taskA);\nmessenger.dispose();\nmessenger.reAppointment(taskB);","handlingStrategy":"validation","validationCode":"if (messenger.hasTask()) messenger.dispose();\nmessenger.reAppointment(task, callback);","typeGuard":null,"tryCatchPattern":"try { messenger.reAppointment(task, cb); } catch (IllegalStateException e) { messenger.dispose(); messenger.reAppointment(task, cb); }","preventionTips":["One messenger per task; never share across tasks.","Always dispose/release before re-appointment.","Use FileDownloader.create instead of hand-building messengers."],"tags":["android","lifecycle","messenger","reuse"],"backgroundTag":"invalid-state-transition","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"}