{"record":{"id":"ca1898f217a7d047","repo":"apache/dubbo","slug":"tickduration-d-expected-0-tickduration-in-na","errorCode":null,"errorMessage":"tickDuration: %d (expected: 0 < tickDuration in nanos < %d","messagePattern":"tickDuration: (.+?) \\(expected: 0 < tickDuration in nanos < (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java","lineNumber":253,"sourceCode":"            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        }\n        workerThread = threadFactory.newThread(worker);\n\n        this.maxPendingTimeouts = maxPendingTimeouts;\n\n        if (INSTANCE_COUNTER.incrementAndGet() > INSTANCE_COUNT_LIMIT &&\n            WARNED_TOO_MANY_INSTANCES.compareAndSet(false, true)) {\n            reportTooManyInstances();\n        }\n    }\n\n    @Override\n    protected void finalize() throws Throwable {\n        try {\n            super.finalize();\n        } finally {","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java#L235-L271","documentation":"IllegalArgumentException thrown by the HashedWheelTimer constructor as an overflow guard. After converting tickDuration to nanoseconds (unit.toNanos), it checks whether the nanosecond value is so large that multiplying by wheel.length would overflow a long. The message reports the offending tickDuration and the maximum allowed value (Long.MAX_VALUE / wheel.length). This prevents arithmetic overflow in the tick-scheduling math (tickDuration * tick in waitForNextTick).","triggerScenarios":"Passing an extremely large tickDuration relative to the wheel size — e.g., tickDuration = Long.MAX_VALUE with a unit of SECONDS, or a very large value in a coarse unit (DAYS/HOURS) that converts to a nanosecond value exceeding Long.MAX_VALUE / wheel.length. The combination of large duration and wheel size makes the internal tick deadline computation overflow.","commonSituations":"Configuration that specifies a timeout interval in DAYS or HOURS that is unreasonably large; unit mismatch causing a value intended as milliseconds to be interpreted as a larger unit; computed durations from arithmetic that accidentally produces huge values.","solutions":["Use a reasonable tickDuration — 100ms is standard for I/O timeouts. If you need very long timeouts, use a larger wheel size or schedule tasks with the intended absolute deadline, not the tick duration.","Ensure the unit matches the magnitude: if the value is in milliseconds, pass TimeUnit.MILLISECONDS, not TimeUnit.SECONDS.","Cap the tickDuration to a sane maximum before construction."],"exampleFix":"// before — huge tick duration in hours\nnew HashedWheelTimer(factory, Long.MAX_VALUE, TimeUnit.HOURS, 512);\n\n// after — reasonable tick with long timeouts handled by wheel rounds\nnew HashedWheelTimer(factory, 100, TimeUnit.MILLISECONDS, 512);","handlingStrategy":"validation","validationCode":"long tickNanos = unit.toNanos(tickDuration);\nlong maxNanos = Long.MAX_VALUE / 512; // or the actual wheel size\nif (tickNanos >= maxNanos) {\n    throw new IllegalArgumentException(\"tickDuration too large for wheel size\");\n}\nnew HashedWheelTimer(factory, tickDuration, unit, ticksPerWheel);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use reasonable tick durations (milliseconds range) — the timer is for I/O timeouts, not hour-long ticks.","Verify the TimeUnit matches the magnitude of the value to avoid accidental inflation.","Cap tickDuration to a sane maximum before construction if it comes from untrusted configuration."],"tags":["timer","overflow","validation","constructor"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}