lingochamp/FileDownloader · error · IllegalAccessException
redirect too many times!
Error message
redirect too many times! %s
What it means
Thrown by RedirectHandler.process when a download request follows more redirect hops than the handler allows (the redirect chain exceeds the configured maximum number of times). This guards against redirect loops or excessively long chains (e.g. misconfigured servers bouncing between URLs) that would otherwise hang the download indefinitely.
Solutions
- Fix the server-side redirect loop so the chain terminates at a real resource.
- Download directly from the final URL shown in the redirectLocationList logged before the throw.
- Catch the exception in the download error callback and surface it to the user or retry with a corrected URL.
- Reduce hop count by hosting the file at a stable, non-chained URL.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at library/src/main/java/com/liulishuo/filedownloader/connection/RedirectHandler.java:85 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/d877da09726296bf.
Report an issue: GitHub.
Appendix: source
Thrown at library/src/main/java/com/liulishuo/filedownloader/connection/RedirectHandler.java:85
code, redirectConnection.getResponseHeaderFields()));
}
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(RedirectHandler.class, "redirect to %s with %d, %s",
location, code, redirectLocationList);
}
redirectConnection.ending();
redirectConnection =
buildRedirectConnection(requestHeaderFields, location);
redirectLocationList.add(location);
redirectConnection.execute();
code = redirectConnection.getResponseCode();
location = redirectConnection.getResponseHeaderField("Location");
if (++redirectTimes >= MAX_REDIRECT_TIMES) {
throw new IllegalAccessException(
FileDownloadUtils
.formatString("redirect too many times! %s", redirectLocationList));
}
}
if (redirectedUrlList != null) {
redirectedUrlList.addAll(redirectLocationList);
}
return redirectConnection;
}
private static boolean isRedirect(int code) {
return code == HttpURLConnection.HTTP_MOVED_PERM
|| code == HttpURLConnection.HTTP_MOVED_TEMP
|| code == HttpURLConnection.HTTP_SEE_OTHER
|| code == HttpURLConnection.HTTP_MULT_CHOICE
|| code == HTTP_TEMPORARY_REDIRECTView on GitHub (pinned to 6237a8cac1)