lingochamp/FileDownloader · error · IllegalAccessException
can't using multi-download when the output stream can't…
Error message
can't using multi-download when the output stream can't support seek
What it means
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.
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at library/src/main/java/com/liulishuo/filedownloader/download/FetchDataTask.java:120 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of lingochamp/FileDownloader@6237a8cac1 (2026-09-08).
Data as JSON: /api/errors/50c86afa80cbaa66.
Report an issue: GitHub.
Appendix: source
Thrown at library/src/main/java/com/liulishuo/filedownloader/download/FetchDataTask.java:120
range = FileDownloadUtils.formatString("range[%d-%d)", currentOffset, endOffset);
}
throw new FileDownloadGiveUpRetryException(FileDownloadUtils.
formatString("require %s with contentLength(%d), but the "
+ "backend response contentLength is %d on "
+ "downloadId[%d]-connectionIndex[%d], please ask your backend "
+ "dev to fix such problem.",
range, this.contentLength, contentLength, downloadId, connectionIndex));
}
final long fetchBeginOffset = currentOffset;
// start fetch
InputStream inputStream = null;
FileDownloadOutputStream outputStream = null;
try {
final boolean isSupportSeek = CustomComponentHolder.getImpl().isSupportSeek();
if (hostRunnable != null && !isSupportSeek) {
throw new IllegalAccessException(
"can't using multi-download when the output stream can't support seek");
}
this.outputStream = outputStream = FileDownloadUtils.createOutputStream(path);
if (isSupportSeek) {
outputStream.seek(currentOffset);
}
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(this, "start fetch(%d): range [%d, %d), seek to[%d]",
connectionIndex, startOffset, endOffset, currentOffset);
}
inputStream = connection.getInputStream();
byte[] buff = new byte[BUFFER_SIZE];
if (paused) return;View on GitHub (pinned to 6237a8cac1)