MuntashirAkon/AppManager · error · IOException

Initialised without a first member nor the…

Error message

Initialised without a first member nor the decompressConcatenated is enabled

What it means

GzipCompressorInputStream.init(isFirstMember) throws this when asked to start a subsequent .gz member while decompressConcatenated is disabled and isFirstMember is false. The stream has finished one member and, because concatenation support is off, reading further input is not allowed.

Solutions

  1. Construct GzipCompressorInputStream with decompressConcatenated=true: new GzipCompressorInputStream(in, true).
  2. If concatenated output is not desired, stop reading at the first member and discard/inspect trailing bytes.
  3. Use CompressorStreamFactory with decompressConcatenated enabled for transparent multi-member handling.

Example fix

// before
GzipCompressorInputStream gz = new GzipCompressorInputStream(in);
// after
GzipCompressorInputStream gz = new GzipCompressorInputStream(in, true); // concatenated members
Defensive patterns

Strategy: validation

Validate before calling

boolean concatenated = true; // if input may contain multiple .gz members
InputStream gz = new GzipCompressorInputStream(rawIn, concatenated);

Try / catch

try (InputStream gz = new GzipCompressorInputStream(rawIn, true)) {
    IOUtils.copy(gz, out);
} catch (IOException e) {
    if (e.getMessage().contains("decompressConcatenated")) {
        // reopen with concatenated mode enabled
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Reading a multi-member (concatenated) .gz file constructed with decompressConcatenated=false; calling read() after the first member's trailer when trailing bytes exist.

Common situations: Files produced by `gzip` of concatenated data or by `tar czf` with multiple passes; users expecting cat-like concatenation semantics but having passed false to the decompressConcatenated constructor flag.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/b4403d895c343da8. Report an issue: GitHub.

Appendix: source

Thrown at app/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java:163

        this.decompressConcatenated = decompressConcatenated;
        init(true);
    }

    /**
     * Provides the stream's meta data - may change with each stream
     * when decompressing concatenated streams.
     *
     * @return the stream's meta data
     * @since 1.8
     */
    public GzipParameters getMetaData() {
        return parameters;
    }

    private boolean init(final boolean isFirstMember) throws IOException {
        if (!isFirstMember && !decompressConcatenated) {
            throw new IOException("Initialised without a first member nor the decompressConcatenated is enabled");
        }

        // Check the magic bytes without a possibility of EOFException.
        final int magic0 = in.read();

        // If end of input was reached after decompressing at least
        // one .gz member, we have reached the end of the file successfully.
        if (magic0 == -1 && !isFirstMember) {
            return false;
        }

        if (magic0 != 31 || in.read() != 139) {
            throw new IOException(isFirstMember ? "Input is not in the .gz format"
                    : "Garbage after a valid .gz stream");
        }

        // Parsing the rest of the header may throw EOFException.
        final DataInput inData = new DataInputStream(in);

View on GitHub (pinned to 0152f468fc)