{"record":{"id":"1fb5272705adf7ac","repo":"jruby/jruby","slug":"stream-error","errorCode":null,"errorMessage":"stream error","messagePattern":"stream error","errorType":"exception","errorClass":"Zlib::StreamError","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/jruby/ext/zlib/JZlibDeflate.java","lineNumber":114,"sourceCode":"    public IRubyObject _initialize(ThreadContext context, IRubyObject[] args) {\n        args = Arity.scanArgs(context, args, 0, 4);\n        level = !args[0].isNil() ? checkLevel(context, toInt(context, args[0])) : -1;\n        windowBits = !args[1].isNil() ? checkWindowBits(context, toInt(context, args[1]), false) : JZlib.MAX_WBITS;\n        int memlevel = !args[2].isNil() ? toInt(context, args[2]) : 8; // ignored. Memory setting means nothing on Java.\n        strategy = !args[3].isNil() ? toInt(context, args[3]) : 0;\n\n        init(context, level, windowBits, memlevel, strategy);\n        return this;\n    }\n\n    private void init(ThreadContext context, int level, int windowBits, int memlevel, int strategy) {\n        flush = JZlib.Z_NO_FLUSH;\n        flater = new com.jcraft.jzlib.Deflater();\n\n        // TODO: Can we expect JZlib to check level, windowBits, and strategy here?\n        // Then we should remove checkLevel, checkWindowsBits and checkStrategy.\n        int err = flater.init(level, windowBits, memlevel);\n        if (err == com.jcraft.jzlib.JZlib.Z_STREAM_ERROR) throw RubyZlib.newStreamError(context, \"stream error\");\n\n        err = flater.params(level, strategy);\n        if (err == com.jcraft.jzlib.JZlib.Z_STREAM_ERROR) throw RubyZlib.newStreamError(context, \"stream error\");\n\n        collected = new byte[BASE_SIZE];\n        collectedIdx = 0;\n    }\n\n    @JRubyMethod(visibility = PRIVATE)\n    public IRubyObject initialize_copy(ThreadContext context, IRubyObject _other) {\n        if (!(_other instanceof JZlibDeflate other)) throw typeError(context, \"Expecting an instance of class JZlibDeflate\");\n        if (this == _other) return this;\n\n        this.level = other.level;\n        this.windowBits = other.windowBits;\n        this.strategy = other.strategy;\n        this.collected = new byte[other.collected.length];\n        System.arraycopy(other.collected, 0, this.collected, 0, other.collected.length);","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/jruby/jruby/blob/fb650c13e02b5a600fa66384655069d5ec30c362/core/src/main/java/org/jruby/ext/zlib/JZlibDeflate.java#L96-L132","documentation":"Error \"stream error\" thrown in jruby/jruby.","triggerScenarios":"Thrown at core/src/main/java/org/jruby/ext/zlib/JZlibDeflate.java:114 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The zlib deflate stream reported an error, usually from an inconsistent stream state or invalid parameters. Recreate the deflater with valid level/strategy and feed well-formed input."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fb650c13e02b5a600fa66384655069d5ec30c362","analyzedAt":"2026-08-23T07:18:57.479Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}