{"record":{"id":"d877da09726296bf","repo":"lingochamp/FileDownloader","slug":"redirect-too-many-times-s","errorCode":null,"errorMessage":"redirect too many times! %s","messagePattern":"redirect too many times! (.+?)","errorType":"exception","errorClass":"IllegalAccessException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/liulishuo/filedownloader/connection/RedirectHandler.java","lineNumber":85,"sourceCode":"                                code, redirectConnection.getResponseHeaderFields()));\n            }\n\n            if (FileDownloadLog.NEED_LOG) {\n                FileDownloadLog.d(RedirectHandler.class, \"redirect to %s with %d, %s\",\n                        location, code, redirectLocationList);\n            }\n\n            redirectConnection.ending();\n            redirectConnection =\n                    buildRedirectConnection(requestHeaderFields, location);\n            redirectLocationList.add(location);\n\n            redirectConnection.execute();\n            code = redirectConnection.getResponseCode();\n            location = redirectConnection.getResponseHeaderField(\"Location\");\n\n            if (++redirectTimes >= MAX_REDIRECT_TIMES) {\n                throw new IllegalAccessException(\n                        FileDownloadUtils\n                                .formatString(\"redirect too many times! %s\", redirectLocationList));\n            }\n        }\n\n        if (redirectedUrlList != null) {\n            redirectedUrlList.addAll(redirectLocationList);\n        }\n\n        return redirectConnection;\n    }\n\n    private static boolean isRedirect(int code) {\n        return code == HttpURLConnection.HTTP_MOVED_PERM\n                || code == HttpURLConnection.HTTP_MOVED_TEMP\n                || code == HttpURLConnection.HTTP_SEE_OTHER\n                || code == HttpURLConnection.HTTP_MULT_CHOICE\n                || code == HTTP_TEMPORARY_REDIRECT","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/lingochamp/FileDownloader/blob/6237a8cac174bcc916e4342b14ab1ab72a5768d4/library/src/main/java/com/liulishuo/filedownloader/connection/RedirectHandler.java#L67-L103","documentation":"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.","triggerScenarios":"Thrown at library/src/main/java/com/liulishuo/filedownloader/connection/RedirectHandler.java:85 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":null,"handlingStrategy":"try-catch","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"}