{"record":{"id":"3190563e2de222dc","repo":"apache/dubbo","slug":"tickduration-must-be-greater-than-0","errorCode":null,"errorMessage":"tickDuration must be greater than 0: {}","messagePattern":"tickDuration must be greater than 0: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java","lineNumber":238,"sourceCode":"     *                           {@link java.util.concurrent.RejectedExecutionException}\n     *                           being thrown. No maximum pending timeouts limit is assumed if\n     *                           this value is 0 or negative.\n     * @throws NullPointerException     if either of {@code threadFactory} and {@code unit} is {@code null}\n     * @throws IllegalArgumentException if either of {@code tickDuration} and {@code ticksPerWheel} is &lt;= 0\n     */\n    public HashedWheelTimer(\n        ThreadFactory threadFactory,\n        long tickDuration, TimeUnit unit, int ticksPerWheel,\n        long maxPendingTimeouts) {\n\n        if (threadFactory == null) {\n            throw new NullPointerException(\"threadFactory\");\n        }\n        if (unit == null) {\n            throw new NullPointerException(\"unit\");\n        }\n        if (tickDuration <= 0) {\n            throw new IllegalArgumentException(\"tickDuration must be greater than 0: \" + tickDuration);\n        }\n        if (ticksPerWheel <= 0) {\n            throw new IllegalArgumentException(\"ticksPerWheel must be greater than 0: \" + ticksPerWheel);\n        }\n\n        // Normalize ticksPerWheel to power of two and initialize the wheel.\n        wheel = createWheel(ticksPerWheel);\n        mask = wheel.length - 1;\n\n        // Convert tickDuration to nanos.\n        this.tickDuration = unit.toNanos(tickDuration);\n\n        // Prevent overflow.\n        if (this.tickDuration >= Long.MAX_VALUE / wheel.length) {\n            throw new IllegalArgumentException(String.format(\n                \"tickDuration: %d (expected: 0 < tickDuration in nanos < %d\",\n                tickDuration, Long.MAX_VALUE / wheel.length));\n        }","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java#L220-L256","documentation":"IllegalArgumentException thrown by the HashedWheelTimer constructor when tickDuration is <= 0. The tick duration defines the interval between wheel ticks (the timer's resolution). A non-positive tick duration is nonsensical — the timer could never advance. The constructor validates this before allocating the wheel structure. Note this checks the raw input value before unit conversion to nanos.","triggerScenarios":"Passing a tickDuration of 0 or a negative number to the HashedWheelTimer constructor. This can happen when the value is read from configuration that defaulted to 0, or computed from a formula that yields zero/negative.","commonSituations":"Configuration property (e.g., a timeout or tick interval) set to 0 or left unset defaulting to 0; computed duration that evaluates to zero due to integer division or unit mismatch; test code passing 0 as a placeholder.","solutions":["Set tickDuration to a positive value — 100 (milliseconds) is the Dubbo/Netty default and is appropriate for most I/O timeout use cases.","Validate the configured/computed tickDuration before construction and fall back to a sensible default.","Check for unit mismatches that cause the value to collapse to 0 (e.g., passing nanoseconds where milliseconds are expected)."],"exampleFix":"// before\nlong tick = config.getTickDuration(); // 0 if unset\nnew HashedWheelTimer(factory, tick, TimeUnit.MILLISECONDS, 512);\n\n// after\nlong tick = config.getTickDuration();\nif (tick <= 0) tick = 100; // default to 100ms\nnew HashedWheelTimer(factory, tick, TimeUnit.MILLISECONDS, 512);","handlingStrategy":"validation","validationCode":"if (tickDuration <= 0) {\n    throw new IllegalArgumentException(\"tickDuration must be positive, got: \" + tickDuration);\n}\n// or default:\nlong safeTick = tickDuration > 0 ? tickDuration : 100L; // 100ms default\nnew HashedWheelTimer(factory, safeTick, unit, ticksPerWheel);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate tickDuration is positive before constructing the timer.","Default to 100 (milliseconds) — the standard resolution for I/O timeouts.","Check configuration parsing to ensure the value isn't accidentally 0."],"tags":["timer","validation","constructor","configuration"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}