MuntashirAkon/AppManager · error · IllegalArgumentException
blockSize(" + blockSize + ") > 9
Error message
blockSize(" + blockSize + ") > 9 What it means
Argument-validation guard in the BZip2CompressorOutputStream constructor: the blockSize parameter (in 100k units) must be between 1 and 9 (MIN_BLOCKSIZE..MAX_BLOCKSIZE); the caller passed a value above 9 (the companion guard handles values below 1), so the stream refuses to allocate an out-of-range Bzip2 block size. Faulty input: the blockSize argument.
Source
Thrown at app/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java:369
* @param blockSize
* the blockSize as 100k units.
*
* @throws IOException
* if an I/O error occurs in the specified stream.
* @throws IllegalArgumentException
* if <code>(blockSize < 1) || (blockSize > 9)</code>.
* @throws NullPointerException
* if <code>out == null</code>.
*
* @see #MIN_BLOCKSIZE
* @see #MAX_BLOCKSIZE
*/
public BZip2CompressorOutputStream(final OutputStream out, final int blockSize) throws IOException {
if (blockSize < 1) {
throw new IllegalArgumentException("blockSize(" + blockSize + ") < 1");
}
if (blockSize > 9) {
throw new IllegalArgumentException("blockSize(" + blockSize + ") > 9");
}
this.blockSize100k = blockSize;
this.out = out;
/* 20 is just a paranoia constant */
this.allowableBlockSize = (this.blockSize100k * BZip2Constants.BASEBLOCKSIZE) - 20;
init();
}
@Override
public void write(final int b) throws IOException {
if (closed) {
throw new IOException("Closed");
}
write0(b);
}
View on GitHub (pinned to 0152f468fc)
Solutions
- Clamp the value into the 1–9 range before constructing the stream.
- Use the one-argument constructor for the default block size (9).
- If users specify sizes in bytes/MB, convert to the bzip2 level: level = (int) Math.min(9, Math.max(1, sizeBytes / 100_000)).
Example fix
// before new BZip2CompressorOutputStream(os, 900_000); // wrong unit // after int level = Math.max(1, Math.min(9, 900_000 / 100_000)); // = 9 new BZip2CompressorOutputStream(os, level);
Defensive patterns
Strategy: validation
Validate before calling
int safeLevel = Math.max(1, Math.min(9, userLevel)); BZip2CompressorOutputStream out = new BZip2CompressorOutputStream(os, safeLevel);
Try / catch
try {
out = new BZip2CompressorOutputStream(os, userLevel);
} catch (IllegalArgumentException e) {
throw new BadConfigException("bzip2 blockSize must be 1-9", e);
} Prevention
- Clamp user/config-supplied levels into 1..9
- Restrict UI inputs to 1–9
- Don't confuse blockSize100k with byte-based sizes from other libraries
- Add a unit test covering boundary values 0, 1, 9, 10
When it happens
Trigger: new BZip2CompressorOutputStream(out, blockSize) with blockSize >= 10, e.g. a user entering '10' or a config value meant as megabytes rather than the 1–9 block-size code.
Common situations: Confusing blockSize100k (1–9) with byte sizes; copying settings from other libraries that take bytes; UI not constraining input to 1–9.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- blockSize(" + blockSize + ") < 1
- Data directory cannot be empty.
- Invalid source compression type:
- Invalid compression type: ${tarType}
- Unsupported compression type: ${compressionType}
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/37316b158da4dc12.
Report an issue: GitHub.