{"record":{"id":"5050695b4ddc2b66","repo":"MuntashirAkon/AppManager","slug":"invalid-gzip-compression-level-compressionlevel","errorCode":null,"errorMessage":"Invalid gzip compression level: \" + compressionLevel","messagePattern":"Invalid gzip compression level: \" \\+ compressionLevel","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java","lineNumber":36,"sourceCode":"    private String comment;\n    private int operatingSystem = 255; // Unknown OS by default\n\n    public int getCompressionLevel() {\n        return compressionLevel;\n    }\n\n    /**\n     * Sets the compression level.\n     *\n     * @param compressionLevel the compression level (between 0 and 9)\n     * @see Deflater#NO_COMPRESSION\n     * @see Deflater#BEST_SPEED\n     * @see Deflater#DEFAULT_COMPRESSION\n     * @see Deflater#BEST_COMPRESSION\n     */\n    public void setCompressionLevel(final int compressionLevel) {\n        if (compressionLevel < -1 || compressionLevel > 9) {\n            throw new IllegalArgumentException(\"Invalid gzip compression level: \" + compressionLevel);\n        }\n        this.compressionLevel = compressionLevel;\n    }\n\n    public long getModificationTime() {\n        return modificationTime;\n    }\n\n    /**\n     * Sets the modification time of the compressed file.\n     *\n     * @param modificationTime the modification time, in milliseconds\n     */\n    public void setModificationTime(final long modificationTime) {\n        this.modificationTime = modificationTime;\n    }\n\n    public String getFilename() {","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java#L18-L54","documentation":"GzipParameters.setCompressionLevel validates the level against the zlib range: only -1 (DEFAULT_COMPRESSION) through 9 (BEST_COMPRESSION) are legal. Values outside that range are rejected with IllegalArgumentException before they can reach the native deflater.","triggerScenarios":"Calling setCompressionLevel with any int < -1 or > 9, e.g. 0, 10, or an uninitialized/miscomputed variable.","commonSituations":"Confusing 1-9 scale with 0-9 or 0-100 scales from other libraries; using a constant from a different API (e.g. Deflater.BEST_COMPRESSION misuse); passing user-supplied config without clamping.","solutions":["Use a value between -1 and 9, e.g. Deflater.DEFAULT_COMPRESSION (-1), BEST_SPEED (1), or BEST_COMPRESSION (9)","Clamp or validate user/config input before calling setCompressionLevel","Use the built-in constants instead of magic numbers"],"exampleFix":"// before\nparams.setCompressionLevel(10); // IllegalArgumentException\n// after\nparams.setCompressionLevel(Deflater.BEST_COMPRESSION); // 9","handlingStrategy":"validation","validationCode":"if (level < -1 || level > 9) throw new IllegalArgumentException(\"gzip level must be -1..9, got \" + level);","typeGuard":null,"tryCatchPattern":"try { params.setCompressionLevel(level); } catch (IllegalArgumentException e) { log.warn(e.getMessage()); params.setCompressionLevel(Deflater.DEFAULT_COMPRESSION); }","preventionTips":["Use Deflater constants (BEST_SPEED..BEST_COMPRESSION) instead of magic numbers","Clamp user/config input: Math.max(-1, Math.min(9, level))","Document the valid -1..9 range where the level is configured"],"tags":["gzip","configuration","validation"],"backgroundTag":"value-out-of-range","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}