lingochamp/FileDownloader · error · NoFieldException
getEtag
Error message
getEtag
What it means
MessageSnapshot's base getEtag() throws NoFieldException because this snapshot type carries no ETag field. Only connected-status snapshots (which hold the HTTP ETag from the server response) override getEtag(); calling it on any other snapshot type is invalid.
Solutions
- Call getEtag() only when getStatus() == FileDownloadStatus.connected
- Retrieve the ETag from the HTTP layer or task data you control instead of the snapshot
- Catch IllegalStateException around the accessor when processing snapshots generically
- If ETag persistence matters, record it in your own storage at the connected callback point
Example fix
// before String etag = snapshot.getEtag(); // after String etag = snapshot.getStatus() == FileDownloadStatus.connected ? snapshot.getEtag() : null;
Defensive patterns
Strategy: validation
Validate before calling
if (snapshot.getStatus() != FileDownloadStatus.connected) {
return null; // no ETag field on this snapshot
} Type guard
String safeGetEtag(IMessageSnapshot s) {
if (s.getStatus() != FileDownloadStatus.connected) return null;
try { return s.getEtag(); } catch (IllegalStateException e) { return null; }
} Try / catch
try {
String etag = snapshot.getEtag();
} catch (IllegalStateException e) {
// snapshot has no etag field for this status
} Prevention
- Call getEtag() only on connected-status snapshots
- Persist the ETag yourself at the connected callback instead of probing later messages
- Guard snapshot accessors by status checks
- Catch IllegalStateException in any generic snapshot iteration code
When it happens
Trigger: Calling IMessageSnapshot.getEtag() on a MessageSnapshot whose class is not a ConnectedMessageSnapshot — e.g. pending, progress, or error snapshots. Triggered through update/handoverMessage message inspection or direct snapshot probing.
Common situations: Breakpoint-resume logic that wants the server ETag from every lifecycle message; code caching ETags without filtering for the connected status; version mismatches where the callback contract changed.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- getThrowable
- getRetryingTimes
- isResuming
- fetched length[ ] != content length[ ], range[ , ) offset[…
- listener must not be null!
AI-assisted analysis of lingochamp/FileDownloader@6237a8cac1 (2026-09-08).
Data as JSON: /api/errors/3b19f0eb0f727331.
Report an issue: GitHub.
Appendix: source
Thrown at library/src/main/java/com/liulishuo/filedownloader/message/MessageSnapshot.java:58
@Override
public Throwable getThrowable() {
throw new NoFieldException("getThrowable", this);
}
@Override
public int getRetryingTimes() {
throw new NoFieldException("getRetryingTimes", this);
}
@Override
public boolean isResuming() {
throw new NoFieldException("isResuming", this);
}
@Override
public String getEtag() {
throw new NoFieldException("getEtag", this);
}
@Override
public long getLargeSofarBytes() {
throw new NoFieldException("getLargeSofarBytes", this);
}
@Override
public long getLargeTotalBytes() {
throw new NoFieldException("getLargeTotalBytes", this);
}
@Override
public int getSmallSofarBytes() {
throw new NoFieldException("getSmallSofarBytes", this);
}
@OverrideView on GitHub (pinned to 6237a8cac1)