{"record":{"id":"9b68ef777abbc89e","repo":"lingochamp/FileDownloader","slug":"this-task-is-running-d-if-you-want-to-start-the","errorCode":null,"errorMessage":"This task is running %d, if you want to start the same task, please create a new one by FileDownloader.create","messagePattern":"This task is running (.+?), if you want to start the same task, please create a new one by FileDownloader\\.create","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/liulishuo/filedownloader/DownloadTask.java","lineNumber":314,"sourceCode":"                    + \" other words, If this task doesn't belong to a queue, you must not invoke\"\n                    + \" BaseDownloadTask#ready() method or InQueueTask#enqueue() method before\"\n                    + \" invoke BaseDownloadTask#start(), If you do that and if there is the same\"\n                    + \" listener object to start a queue in another thread, this task may be \"\n                    + \"assembled by the queue, in that case, when you invoke \"\n                    + \"BaseDownloadTask#start() manually to start this task or this task is started\"\n                    + \" by the queue, there is an exception buried in there, because this task\"\n                    + \" object is started two times without declare BaseDownloadTask#reuse() :\"\n                    + \" 1. you invoke BaseDownloadTask#start() manually; \"\n                    + \" 2. the queue start this task automatically.\");\n        }\n\n        return startTaskUnchecked();\n    }\n\n    private int startTaskUnchecked() {\n        if (isUsing()) {\n            if (isRunning()) {\n                throw new IllegalStateException(\n                        FileDownloadUtils.formatString(\"This task is running %d, if you\"\n                                + \" want to start the same task, please create a new one by\"\n                                + \" FileDownloader.create\", getId()));\n            } else {\n                throw new IllegalStateException(\"This task is dirty to restart, If you want to \"\n                        + \"reuse this task, please invoke #reuse method manually and retry to \"\n                        + \"restart again.\" + mHunter.toString());\n            }\n        }\n\n        if (!isAttached()) {\n            setAttachKeyDefault();\n        }\n\n        mHunter.intoLaunchPool();\n\n        return getId();\n    }","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/lingochamp/FileDownloader/blob/6237a8cac174bcc916e4342b14ab1ab72a5768d4/library/src/main/java/com/liulishuo/filedownloader/DownloadTask.java#L296-L332","documentation":"startTaskUnchecked() throws this IllegalStateException when starting a task that is currently running (isUsing() && isRunning()). FileDownloader task objects are single-use while running; to repeat the download you must create a fresh task via FileDownloader.create.","triggerScenarios":"Calling start() (manually, from a queue, or from rescue) on a DownloadTask that is already in the running state.","commonSituations":"Reusing a captured task variable to retry a download while the first attempt is still active; click handlers that start the same task object repeatedly.","solutions":["Create a new task with FileDownloader.getImpl().create(url, path) before starting again.","Check the task status before starting (FileDownloader.getImpl().getStatus(...)) and skip if already running.","If the previous run finished, call task.reuse() then restart."],"exampleFix":"// before\nif (!task.isRunning()) return;\ntask.start();\n\n// after\nif (FileDownloader.getImpl().getStatus(url, path)) return;\nDownloadTask task = FileDownloader.getImpl().create(url, path);\ntask.start();","handlingStrategy":"validation","validationCode":"if (FileDownloader.getImpl().getStatus(url, path)) return; // already running\nDownloadTask task = FileDownloader.getImpl().create(url, path);\ntask.start();","typeGuard":"boolean safeToStart(BaseDownloadTask t) { return !t.isRunning(); }","tryCatchPattern":null,"preventionTips":["Always create a fresh task per start via FileDownloader.create.","Check FileDownloader.getImpl().getStatus(url, path) before starting.","Disable UI trigger while a download is in flight."],"tags":["android","task-lifecycle","duplicate-start"],"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"}