{"record":{"id":"b97d6e0f0968aca4","repo":"lingochamp/FileDownloader","slug":"getretryingtimes","errorCode":null,"errorMessage":"getRetryingTimes","messagePattern":"getRetryingTimes","errorType":"exception","errorClass":"NoFieldException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/liulishuo/filedownloader/message/MessageSnapshot.java","lineNumber":48,"sourceCode":"    protected boolean isLargeFile;\n\n    MessageSnapshot(int id) {\n        this.id = id;\n    }\n\n    @Override\n    public int getId() {\n        return id;\n    }\n\n    @Override\n    public Throwable getThrowable() {\n        throw new NoFieldException(\"getThrowable\", this);\n    }\n\n    @Override\n    public int getRetryingTimes() {\n        throw new NoFieldException(\"getRetryingTimes\", this);\n    }\n\n    @Override\n    public boolean isResuming() {\n        throw new NoFieldException(\"isResuming\", this);\n    }\n\n    @Override\n    public String getEtag() {\n        throw new NoFieldException(\"getEtag\", this);\n    }\n\n    @Override\n    public long getLargeSofarBytes() {\n        throw new NoFieldException(\"getLargeSofarBytes\", this);\n    }\n\n    @Override","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/lingochamp/FileDownloader/blob/6237a8cac174bcc916e4342b14ab1ab72a5768d4/library/src/main/java/com/liulishuo/filedownloader/message/MessageSnapshot.java#L30-L66","documentation":"MessageSnapshot's base getRetryingTimes() throws NoFieldException because the snapshot class does not carry a 'retrying times' field. Only retry-status snapshots override this method with a meaningful value; accessing it on any other snapshot type is invalid.","triggerScenarios":"Calling IMessageSnapshot.getRetryingTimes() on a MessageSnapshot that is not a RetryMessageSnapshot (e.g. pending, progress, completed snapshots). Reached via the internal update/handoverMessage message pipeline when code probes retry info generically.","commonSituations":"Generic message handling code that reads retryingTimes for every status; custom listeners that assume retryingTimes is always populated; version differences where the callback API no longer routes through the snapshot.","solutions":["Guard the call with getStatus() == FileDownloadStatus.retry before reading getRetryingTimes()","Obtain retry counts from BaseDownloadTask (getRetryingTimes on the task) rather than the snapshot","Catch IllegalStateException around the accessor when processing heterogeneous snapshots","Do not construct or probe raw MessageSnapshots yourself; rely on FileDownloaderListener callbacks"],"exampleFix":"// before\nint times = snapshot.getRetryingTimes();\n// after\nint times = snapshot.getStatus() == FileDownloadStatus.retry ? snapshot.getRetryingTimes() : 0;","handlingStrategy":"validation","validationCode":"if (snapshot.getStatus() != FileDownloadStatus.retry) {\n    return 0; // no retrying-times field on this snapshot\n}","typeGuard":"int safeGetRetryingTimes(IMessageSnapshot s) {\n    if (s.getStatus() != FileDownloadStatus.retry) return 0;\n    try { return s.getRetryingTimes(); } catch (IllegalStateException e) { return 0; }\n}","tryCatchPattern":"try {\n    int times = snapshot.getRetryingTimes();\n} catch (IllegalStateException e) {\n    // snapshot has no retrying-times field for this status\n}","preventionTips":["Only call getRetryingTimes() on retry-status snapshots","Get retry counts from BaseDownloadTask rather than message snapshots","Guard every snapshot accessor with a status check","Treat NoFieldException (IllegalStateException) as a signal of wrong-status access"],"tags":["android","filedownloader","no-field","snapshot-accessor"],"backgroundTag":"unsupported-operation","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"}