MuntashirAkon/AppManager · error · IllegalArgumentException
blockSize(" + blockSize + ") < 1
Error message
blockSize(" + blockSize + ") < 1 What it means
The BZip2CompressorOutputStream(out, blockSize) constructor requires a blockSize100k parameter between 1 and 9 (meaning 100k–900k blocks). Passing 0 or a negative number is rejected immediately with this IllegalArgumentException — it is a programming/config error, not an I/O problem.
Source
Thrown at app/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java:366
*
* @param out
* the destination stream.
* @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");
}View on GitHub (pinned to 0152f468fc)
Solutions
- Pass a blockSize between 1 and 9, or use the single-argument constructor BZip2CompressorOutputStream(out) which uses the default.
- Clamp or default invalid configured values before constructing (Math.max(1, Math.min(9, value))).
- If blockSize comes from config, validate it at startup with a clear message.
Example fix
// before
int blockSize = Integer.parseInt(cfg.get("blocksize")); // 0 when unset
BZip2CompressorOutputStream out = new BZip2CompressorOutputStream(os, blockSize);
// after
int blockSize = Math.max(1, Math.min(9, Integer.parseInt(cfg.getOrDefault("blocksize", "9"))));
BZip2CompressorOutputStream out = new BZip2CompressorOutputStream(os, blockSize); Defensive patterns
Strategy: validation
Validate before calling
// validate before constructing
if (blockSize < 1 || blockSize > 9)
throw new IllegalArgumentException("blockSize must be 1..9, got " + blockSize); Try / catch
try {
out = new BZip2CompressorOutputStream(os, configuredBlockSize);
} catch (IllegalArgumentException e) {
out = new BZip2CompressorOutputStream(os); // fall back to default
log.warn("bad blockSize config, using default", e);
} Prevention
- Validate compression-level config at startup
- Prefer the single-argument constructor when the level is not user-controlled
- Clamp external config into 1..9
- Document that blockSize is the bzip2 level (100k units), not bytes
When it happens
Trigger: new BZip2CompressorOutputStream(out, 0) or any negative blockSize; typically blockSize read from config/env that defaulted to 0.
Common situations: Config property like 'compress.blocksize' missing or parsed to 0, user-supplied value not clamped, refactored code passing an uninitialized int.
Related errors
- blockSize(" + blockSize + ") > 9
- Block size must be a multiple of 512 bytes. Attempt to use s
- The app has keystore items and KeyStore backup isn't enabled
- Data directory cannot be empty.
- Invalid source compression type:
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/c80819717a015c75.
Report an issue: GitHub.