MuntashirAkon/AppManager · error · IllegalStateException
No current tar entry
Error message
No current tar entry
What it means
Thrown by TarArchiveInputStream.read when there is no current entry to read from. Reading is positional: you must first advance the stream with getNextEntry/getNextTarEntry before calling read; otherwise the stream has no entry context.
Solutions
- Call getNextTarEntry()/getNextEntry() and check for non-null before every read loop
- Stop the read loop as soon as getNextEntry() returns null
- Create a new TarArchiveInputStream instead of reusing an exhausted one
- Guard reads with a currEntry != null check (which is what read() itself does internally)
Example fix
// before
TarArchiveEntry entry = tin.getNextTarEntry();
byte[] data = new byte[1024];
tin.read(data); // crashes if entry was null
// after
TarArchiveEntry entry = tin.getNextTarEntry();
if (entry != null) {
byte[] data = new byte[1024];
tin.read(data);
} Defensive patterns
Strategy: validation
Validate before calling
TarArchiveEntry entry = tin.getNextTarEntry();
if (entry == null) { throw new IOException("no entry available to read"); } Type guard
boolean hasCurrentEntry(TarArchiveInputStream in, TarArchiveEntry current) { return current != null; } Try / catch
try {
tin.read(buf, 0, buf.length);
} catch (IllegalStateException e) {
if ("No current tar entry".equals(e.getMessage())) {
throw new IOException("Call getNextTarEntry() before reading", e);
}
throw e;
} Prevention
- Always iterate with getNextTarEntry() and check for null before reading
- Never reuse an exhausted TarArchiveInputStream
- Structure read loops as: while ((e = in.getNextTarEntry()) != null) { readFully(e); }
When it happens
Trigger: Calling read(byte[],int,int) before the first getNextEntry() call, after getNextEntry() returned null (EOF), or after close() — e.g. in getLongNameData when the entry state was lost.
Common situations: Reading entries without iterating via getNextTarEntry; reusing a stream object after exhausting it; off-by-one loop conditions that read one extra time after null.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- No current entry to close
- No current tar entry
- This archive has already been finished
- APK files backup is requested but no APK files have been…
- APK files backup is requested but no APK files have been…
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/87644161ca6a3aae.
Report an issue: GitHub.
Appendix: source
Thrown at app/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java:712
* @param buf The buffer into which to place bytes read.
* @param offset The offset at which to place bytes read.
* @param numToRead The number of bytes to read.
* @return The number of bytes read, or -1 at EOF.
* @throws IOException on error
*/
@Override
public int read(final byte[] buf, final int offset, int numToRead) throws IOException {
if (numToRead == 0) {
return 0;
}
int totalRead = 0;
if (isAtEOF() || isDirectory()) {
return -1;
}
if (currEntry == null) {
throw new IllegalStateException("No current tar entry");
}
if (!currEntry.isSparse()) {
if (entryOffset >= entrySize) {
return -1;
}
} else {
// for sparse entries, there are actually currEntry.getRealSize() bytes to read
if (entryOffset >= currEntry.getRealSize()) {
return -1;
}
}
numToRead = Math.min(numToRead, available());
if (currEntry.isSparse()) {
// for sparse entries, we need to read them in another way
totalRead = readSparse(buf, offset, numToRead);View on GitHub (pinned to 0152f468fc)