MuntashirAkon/AppManager · error · IOException
No InputStream
Error message
No InputStream
What it means
init() throws IOException("No InputStream") when the internal bin reference is null, meaning the stream was constructed without a source or the source was already released. It is an internal precondition check before reading the BZip2 header.
Source
Thrown at app/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java:225
case NO_RAND_PART_B_STATE:
return setupNoRandPartB();
case NO_RAND_PART_C_STATE:
return setupNoRandPartC();
default:
throw new IllegalStateException();
}
}
private int readNextByte(final BitInputStream in) throws IOException {
final long b = in.readBits(8);
return (int) b;
}
private boolean init(final boolean isFirstStream) throws IOException {
if (null == bin) {
throw new IOException("No InputStream");
}
if (!isFirstStream) {
bin.clearBitCache();
}
final int magic0 = readNextByte(this.bin);
if (magic0 == -1 && !isFirstStream) {
return false;
}
final int magic1 = readNextByte(this.bin);
final int magic2 = readNextByte(this.bin);
if (magic0 != 'B' || magic1 != 'Z' || magic2 != 'h') {
throw new IOException(isFirstStream
? "Stream is not in the BZip2 format"
: "Garbage after a valid BZip2 stream");
}View on GitHub (pinned to 0152f468fc)
Solutions
- Construct a new BZip2CompressorInputStream with a non-null InputStream instead of reusing a closed one.
- Do not call private init() paths indirectly after close(); create a fresh stream for each logical input.
- Ensure the constructor receives a valid, open InputStream.
Example fix
// before in.close(); in.read(); // triggers init on closed stream // after in.close(); BZip2CompressorInputStream in2 = new BZip2CompressorInputStream(new FileInputStream(file));
Defensive patterns
Strategy: validation
Validate before calling
if (inputStream == null) throw new IllegalArgumentException("InputStream required");
BZip2CompressorInputStream in = new BZip2CompressorInputStream(inputStream); Type guard
static boolean isReady(BZip2CompressorInputStream s) { return s != null; } Try / catch
try {
init(...);
} catch (IOException e) {
if ("No InputStream".equals(e.getMessage())) {
throw new IllegalStateException("stream used without a source");
}
throw e;
} Prevention
- Never construct or reuse the stream with a null InputStream.
- Create a fresh stream instance per input file/connection.
- Do not drive the stream after close().
When it happens
Trigger: Calling read()/close-related flows that trigger lazy init (via the constructor or complete() for concatenated streams) after the stream was closed and bin set to null.
Common situations: Reusing a closed stream instance for concatenated-stream continuation; custom subclasses invoking init manually; constructing with a null InputStream and bypassing the constructor check.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/9cf4755b8b3d772c.
Report an issue: GitHub.