{"record":{"id":"9b8c7e69aff38b03","repo":"ReactiveX/RxJava","slug":"paramname-0-required-but-it-was-value","errorCode":null,"errorMessage":"{paramName} > 0 required but it was {value}","messagePattern":"(.+?) > 0 required but it was (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/reactivex/rxjava4/internal/functions/ObjectHelper.java","lineNumber":52,"sourceCode":"     * @param <T> the value type\n     * @return the bi-predicate instance\n     */\n    @SuppressWarnings(\"unchecked\")\n    public static <T> BiPredicate<T, T> equalsPredicate() {\n        return (BiPredicate<T, T>)EQUALS;\n    }\n\n    /**\n     * Validate that the given value is positive or report an IllegalArgumentException with\n     * the parameter name.\n     * @param value the value to validate\n     * @param paramName the parameter name of the value\n     * @return value\n     * @throws IllegalArgumentException if bufferSize &lt;= 0\n     */\n    public static int verifyPositive(int value, String paramName) {\n        if (value <= 0) {\n            throw new IllegalArgumentException(paramName + \" > 0 required but it was \" + value);\n        }\n        return value;\n    }\n\n    /**\n     * Validate that the given value is positive or report an IllegalArgumentException with\n     * the parameter name.\n     * @param value the value to validate\n     * @param paramName the parameter name of the value\n     * @return value\n     * @throws IllegalArgumentException if bufferSize &lt;= 0\n     */\n    public static long verifyPositive(long value, String paramName) {\n        if (value <= 0L) {\n            throw new IllegalArgumentException(paramName + \" > 0 required but it was \" + value);\n        }\n        return value;\n    }","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/ReactiveX/RxJava/blob/a8ab5356143f37a8f1dd6d76c79191bec5fa343b/src/main/java/io/reactivex/rxjava4/internal/functions/ObjectHelper.java#L34-L70","documentation":"Thrown by ObjectHelper.verifyPositive(int, String) when value <= 0. This helper validates buffer sizes, prefetch amounts, concurrency limits, and other strictly-positive integer parameters across the library, embedding the offending parameter name in the message for easy diagnosis.","triggerScenarios":"Calling an operator that internally delegates to verifyPositive with a non-positive int: e.g. buffer(capacity) with capacity <= 0, flowableOnBackpressureBuffer(capacity) with capacity <= 0, or any API whose @param documents 'positive'. Also triggered by calling verifyPositive directly.","commonSituations":"Config-driven buffer/prefetch sizes defaulting to 0 or -1 when unset; computing capacity from expressions that can reach zero (e.g. pool size minus reserve); passing a literal 0 by mistake instead of a meaningful default.","solutions":["Ensure the int value is >= 1 before invoking the operator; clamp with Math.max(1, value).","Fix the config/source so the value cannot be non-positive (reject 0/-1 at parse time).","Pick a sensible positive default (e.g. 128 for buffers) when the configured value is absent or invalid.","Add a boundary test: value 1 succeeds, value 0 throws, negative throws."],"exampleFix":"// before\nint buf = config.getInt(\"buffer\", 0);\nsource.buffer(buf).blockingSubscribe(...);\n\n// after\nint buf = Math.max(1, config.getInt(\"buffer\", 128));\nsource.buffer(buf).blockingSubscribe(...);","handlingStrategy":"validation","validationCode":"int safePositive(int v, String name) {\n    return ObjectHelper.verifyPositive(Math.max(1, v), name);\n}\n// or simply: int buf = Math.max(1, configured);","typeGuard":null,"tryCatchPattern":"try {\n    source.buffer(buf).blockingSubscribe(...);\n} catch (IllegalArgumentException e) {\n    // buf <= 0; pick a positive default and retry\n}","preventionTips":["Always choose a positive default (e.g. 128) for buffer/prefetch config.","Reject 0/-1 at config parse time.","Boundary-test with 1 (ok), 0 (throws), and negative (throws)."],"tags":["validation","argument","objecthelper","buffer","prefetch","rxjava"],"backgroundTag":null,"analyzedSha":"a8ab5356143f37a8f1dd6d76c79191bec5fa343b","analyzedAt":"2026-08-13T23:25:30.069Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}