{"record":{"id":"9cf4755b8b3d772c","repo":"MuntashirAkon/AppManager","slug":"no-inputstream","errorCode":null,"errorMessage":"No InputStream","messagePattern":"No InputStream","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java","lineNumber":225,"sourceCode":"            case NO_RAND_PART_B_STATE:\n                return setupNoRandPartB();\n\n            case NO_RAND_PART_C_STATE:\n                return setupNoRandPartC();\n\n            default:\n                throw new IllegalStateException();\n        }\n    }\n\n    private int readNextByte(final BitInputStream in) throws IOException {\n        final long b = in.readBits(8);\n        return (int) b;\n    }\n\n    private boolean init(final boolean isFirstStream) throws IOException {\n        if (null == bin) {\n            throw new IOException(\"No InputStream\");\n        }\n\n        if (!isFirstStream) {\n            bin.clearBitCache();\n        }\n\n        final int magic0 = readNextByte(this.bin);\n        if (magic0 == -1 && !isFirstStream) {\n            return false;\n        }\n        final int magic1 = readNextByte(this.bin);\n        final int magic2 = readNextByte(this.bin);\n\n        if (magic0 != 'B' || magic1 != 'Z' || magic2 != 'h') {\n            throw new IOException(isFirstStream\n                    ? \"Stream is not in the BZip2 format\"\n                    : \"Garbage after a valid BZip2 stream\");\n        }","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java#L207-L243","documentation":"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.","triggerScenarios":"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.","commonSituations":"Reusing a closed stream instance for concatenated-stream continuation; custom subclasses invoking init manually; constructing with a null InputStream and bypassing the constructor check.","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."],"exampleFix":"// before\nin.close();\nin.read(); // triggers init on closed stream\n// after\nin.close();\nBZip2CompressorInputStream in2 = new BZip2CompressorInputStream(new FileInputStream(file));","handlingStrategy":"validation","validationCode":"if (inputStream == null) throw new IllegalArgumentException(\"InputStream required\");\nBZip2CompressorInputStream in = new BZip2CompressorInputStream(inputStream);","typeGuard":"static boolean isReady(BZip2CompressorInputStream s) { return s != null; }","tryCatchPattern":"try {\n    init(...);\n} catch (IOException e) {\n    if (\"No InputStream\".equals(e.getMessage())) {\n        throw new IllegalStateException(\"stream used without a source\");\n    }\n    throw e;\n}","preventionTips":["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()."],"tags":["io","null-check","lifecycle"],"backgroundTag":"missing-required-argument","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}