{"record":{"id":"d2ff47d6bfdb561c","repo":"pinpoint-apm/pinpoint","slug":"negative-tick","errorCode":null,"errorMessage":"negative tick","messagePattern":"negative tick","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/clock/TickClock.java","lineNumber":15,"sourceCode":"package com.navercorp.pinpoint.common.profiler.clock;\n\nimport java.util.Objects;\n\n/**\n * @author Woonduk Kang(emeroad)\n */\npublic class TickClock implements Clock {\n    private final Clock baseClock;\n    private final long tick;\n\n    public TickClock(Clock baseClock, long tick) {\n        this.baseClock = Objects.requireNonNull(baseClock, \"baseClock\");\n        if (tick < 0) {\n            throw new IllegalArgumentException(\"negative tick\");\n        }\n        this.tick = tick;\n    }\n\n    public long millis() {\n        long millis = baseClock.millis();\n        return tick(millis);\n    }\n\n    public long tick(long millis) {\n        return millis - (millis % tick);\n    }\n\n}\n\n","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/clock/TickClock.java#L1-L31","documentation":"TickClock composes a base Clock with a fixed tick interval (in milliseconds). The constructor validates the tick argument and throws IllegalArgumentException(\"negative tick\") when a negative interval is supplied, since a negative clock resolution is meaningless.","triggerScenarios":"Constructing new TickClock(baseClock, tick) with tick < 0, e.g. passing a computed or configured interval that resolved to a negative value.","commonSituations":"Configuration mistakes where the sampling/clock interval is parsed from config and a negative or miscomputed value (e.g. subtraction overflow, wrong sign) is passed in.","solutions":["Pass a non-negative tick value (>= 0) to the TickClock constructor","Validate/normalize the configured interval before constructing TickClock","Fix the source of the negative value (config parsing, subtraction order, overflow)","Clamp with Math.max(0, tick) if a zero interval is an acceptable default"],"exampleFix":"// before\nlong tick = end - start; // could be negative\nTickClock clock = new TickClock(baseClock, tick);\n// after\nlong tick = Math.max(0, end - start);\nTickClock clock = new TickClock(baseClock, tick);","handlingStrategy":"validation","validationCode":"if (tick < 0) throw new IllegalArgumentException(\"tick must be >= 0: \" + tick);\nTickClock clock = new TickClock(baseClock, tick);","typeGuard":"boolean isValidTick(long tick) { return tick >= 0; }","tryCatchPattern":"try { clock = new TickClock(baseClock, tick); } catch (IllegalArgumentException e) { clock = new TickClock(baseClock, 0); }","preventionTips":["Validate configured intervals before constructing clocks","Watch for subtraction/overflow producing negative tick values","Use Math.max(0, tick) to clamp computed intervals"],"tags":["clock","illegal-argument","pinpoint","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}