lingochamp/FileDownloader · error · IllegalAccessException
invalid connection count
Error message
invalid connection count %d, the connection count must be larger than 0
What it means
Thrown by DownloadLaunchRunnable.run when the computed connection count for a multi-point (chunked) download is zero or negative. The connection count determines how many parallel range connections split the file; a non-positive value means the model/total-length inspection produced an invalid chunk plan, so the download cannot proceed and is failed with an IllegalArgumentException-style assertion.
Solutions
- Ensure the download is created with a valid connection count (FileDownloadHelper config) larger than 0 when using multi-point download.
- Check that the task model and its resumed state in the database are not corrupted (inspect ConnectionModel rows for the task id).
- Retry the download after clearing its persisted state so the connection plan is recomputed from scratch.
- Catch the error in the download listener's error callback and restart the task with default single-connection settings.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at library/src/main/java/com/liulishuo/filedownloader/download/DownloadLaunchRunnable.java:277 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/e24ed568552cfae6.
Report an issue: GitHub.
Appendix: source
Thrown at library/src/main/java/com/liulishuo/filedownloader/download/DownloadLaunchRunnable.java:277
// 4. check local resume model
final List<ConnectionModel> connectionOnDBList = database
.findConnectionModel(model.getId());
inspectTaskModelResumeAvailableOnDB(connectionOnDBList);
if (paused) {
model.setStatus(FileDownloadStatus.paused);
return;
}
final long totalLength = model.getTotal();
// 5. pre-allocate if need.
handlePreAllocate(totalLength, model.getTempFilePath());
// 6. calculate block count
final int connectionCount = calcConnectionCount(totalLength);
if (connectionCount <= 0) {
throw new IllegalAccessException(FileDownloadUtils
.formatString("invalid connection count %d, the connection count"
+ " must be larger than 0", connectionCount));
}
if (totalLength == 0) {
return;
}
if (paused) {
model.setStatus(FileDownloadStatus.paused);
return;
}
// 7. start real connect and fetch to local filesystem
isSingleConnection = connectionCount == 1;
if (isSingleConnection) {
// single connection
realDownloadWithSingleConnection(totalLength);View on GitHub (pinned to 6237a8cac1)