{"record":{"id":"50c86afa80cbaa66","repo":"lingochamp/FileDownloader","slug":"can-t-using-multi-download-when-the-output-stream","errorCode":null,"errorMessage":"can't using multi-download when the output stream can't support seek","messagePattern":"can't using multi-download when the output stream can't support seek","errorType":"exception","errorClass":"IllegalAccessException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/liulishuo/filedownloader/download/FetchDataTask.java","lineNumber":120,"sourceCode":"                range = FileDownloadUtils.formatString(\"range[%d-%d)\", currentOffset, endOffset);\n            }\n            throw new FileDownloadGiveUpRetryException(FileDownloadUtils.\n                    formatString(\"require %s with contentLength(%d), but the \"\n                                    + \"backend response contentLength is %d on \"\n                                    + \"downloadId[%d]-connectionIndex[%d], please ask your backend \"\n                                    + \"dev to fix such problem.\",\n                            range, this.contentLength, contentLength, downloadId, connectionIndex));\n        }\n\n        final long fetchBeginOffset = currentOffset;\n        // start fetch\n        InputStream inputStream = null;\n        FileDownloadOutputStream outputStream = null;\n\n        try {\n            final boolean isSupportSeek = CustomComponentHolder.getImpl().isSupportSeek();\n            if (hostRunnable != null && !isSupportSeek) {\n                throw new IllegalAccessException(\n                        \"can't using multi-download when the output stream can't support seek\");\n            }\n\n            this.outputStream = outputStream = FileDownloadUtils.createOutputStream(path);\n            if (isSupportSeek) {\n                outputStream.seek(currentOffset);\n            }\n\n            if (FileDownloadLog.NEED_LOG) {\n                FileDownloadLog.d(this, \"start fetch(%d): range [%d, %d), seek to[%d]\",\n                        connectionIndex, startOffset, endOffset, currentOffset);\n            }\n\n            inputStream = connection.getInputStream();\n\n            byte[] buff = new byte[BUFFER_SIZE];\n\n            if (paused) return;","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/lingochamp/FileDownloader/blob/6237a8cac174bcc916e4342b14ab1ab72a5768d4/library/src/main/java/com/liulishuo/filedownloader/download/FetchDataTask.java#L102-L138","documentation":"Thrown when FileDownloader attempts a multi-connection (ranged) download but the destination output stream does not support seek (random-access positioning). Multi-download requires jumping to each connection's offset, which is impossible on non-seekable streams, so the library rejects the configuration up front via FileDownloadGiveUpRetryException rather than producing corrupt output.","triggerScenarios":"Thrown at library/src/main/java/com/liulishuo/filedownloader/download/FetchDataTask.java:120 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Download to a seekable destination such as a file path backed by RandomAccessFile instead of a streaming/wrapper output stream","Set the task to single-connection download (e.g. set the download to non-multi-thread/one connection) so no seeking is required","If a custom output stream is used, implement seek support so ranged writes can be positioned correctly","Verify the connection count configuration is not forcing multi-download when a plain stream target is given"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}