apache/cassandra · error · EOFException
EOF after " + (limit - bytesRead) + " bytes out of " + size
Error message
EOF after " + (limit - bytesRead) + " bytes out of " + size
What it means
TrackedDataInputPlus wraps another input with a read limit. checkCanRead throws EOFException when a read of `size` bytes would exceed the remaining limit, after skipping to the limit boundary. It signals truncated data: fewer bytes were available than the reader requested.
Solutions
- Verify the upstream data source is complete and not truncated (check file size / frame length)
- Validate embedded length prefixes against the available limit before reading
- Check that writer and reader use compatible serialization versions
- Catch EOFException and treat the payload as corrupt, logging the bytes read vs expected
Example fix
// before input.readFully(buffer, 0, declaredLength); // may throw EOFException // after if (declaredLength > availableBytes()) throw new CorruptPayloadException(...); input.readFully(buffer, 0, declaredLength);
Defensive patterns
Strategy: validation
Validate before calling
if (limit >= 0 && needed > limit - bytesRead) throw new EOFException("truncated"); // mirror the check before reading Type guard
boolean canRead(TrackedDataInputPlus in, int n) { return in.available() >= n; } Try / catch
try { in.readFully(buf, 0, n); } catch (EOFException e) { handleTruncated(e); } Prevention
- Validate length prefixes against frame limits before reading
- Check file/frame sizes before deserializing
- Keep serializer versions in sync between writer and reader
- Treat EOFException during decode as data corruption, not a crash
When it happens
Trigger: Any of readBoolean/readByte/readChar/readDouble/readFloat/readFully (and other size-checking reads) requesting more bytes than remain before the configured limit; e.g. reading a length-prefixed field that claims more bytes than the stream contains.
Common situations: Deserializing truncated messages or files; corrupt payloads whose embedded lengths exceed the actual frame size; protocol mismatches between writer and reader versions.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- EOF after " + copied + " bytes out of " + len
- EOF after " + read + " bytes out of " + len
- Cannot deserialize index summary from
- Clustering block upper bits (those not associated with…
- Corrupt clustering value length
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/1d25f4b225f5dfaa.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/io/util/TrackedDataInputPlus.java:204
int i = source.readUnsignedShort();
bytesRead += TypeSizes.SHORT_SIZE;
return i;
}
public int skipBytes(int n) throws IOException
{
int skipped = source.skipBytes(limit < 0 ? n : (int) Math.min(limit - bytesRead, n));
bytesRead += skipped;
return skipped;
}
@Inline
private void checkCanRead(int size) throws IOException
{
if (limit >= 0 && bytesRead + size > limit)
{
skipBytes((int) (limit - bytesRead));
throw new EOFException("EOF after " + (limit - bytesRead) + " bytes out of " + size);
}
}
}
View on GitHub (pinned to 88fd0f6a0e)