pinpoint-apm/pinpoint · error · java.lang.IllegalArgumentException

negative tick

Error message

negative tick

What it means

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.

Source

Thrown at commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/clock/TickClock.java:15

package com.navercorp.pinpoint.common.profiler.clock;

import java.util.Objects;

/**
 * @author Woonduk Kang(emeroad)
 */
public class TickClock implements Clock {
    private final Clock baseClock;
    private final long tick;

    public TickClock(Clock baseClock, long tick) {
        this.baseClock = Objects.requireNonNull(baseClock, "baseClock");
        if (tick < 0) {
            throw new IllegalArgumentException("negative tick");
        }
        this.tick = tick;
    }

    public long millis() {
        long millis = baseClock.millis();
        return tick(millis);
    }

    public long tick(long millis) {
        return millis - (millis % tick);
    }

}

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Pass a non-negative tick value (>= 0) to the TickClock constructor
  2. Validate/normalize the configured interval before constructing TickClock
  3. Fix the source of the negative value (config parsing, subtraction order, overflow)
  4. Clamp with Math.max(0, tick) if a zero interval is an acceptable default

Example fix

// before
long tick = end - start; // could be negative
TickClock clock = new TickClock(baseClock, tick);
// after
long tick = Math.max(0, end - start);
TickClock clock = new TickClock(baseClock, tick);
Defensive patterns

Strategy: validation

Validate before calling

if (tick < 0) throw new IllegalArgumentException("tick must be >= 0: " + tick);
TickClock clock = new TickClock(baseClock, tick);

Type guard

boolean isValidTick(long tick) { return tick >= 0; }

Try / catch

try { clock = new TickClock(baseClock, tick); } catch (IllegalArgumentException e) { clock = new TickClock(baseClock, 0); }

Prevention

When it happens

Trigger: Constructing new TickClock(baseClock, tick) with tick < 0, e.g. passing a computed or configured interval that resolved to a negative value.

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07). Data as JSON: /api/errors/d2ff47d6bfdb561c. Report an issue: GitHub.