pinpoint-apm/pinpoint · error · IllegalArgumentException

negative cache size:${size}

Error message

negative cache size:${size}

What it means

DefaultHierarchyCaches validates its constructor arguments: the cache size must be strictly positive. Passing size <= 0 throws IllegalArgumentException 'negative cache size:<size>' before any caching structure is built.

Source

Thrown at agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/transformer/DefaultHierarchyCaches.java:35

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
import com.navercorp.pinpoint.profiler.cache.CaffeineBuilder;

/**
 * @author jaehong.kim
 */
public class DefaultHierarchyCaches implements HierarchyCaches {
    private static final int MAX = 64;

    private final LoadingCache<String, Hierarchy> caches;
    private final int cacheSize;
    private final int cacheEntrySize;

    public DefaultHierarchyCaches(final int size, final int entrySize) {
        if (size <= 0) {
            throw new IllegalArgumentException("negative cache size:" + size);
        }

        this.cacheSize = getCacheSize(size);

        this.cacheEntrySize = getCacheEntrySize(entrySize);

        this.caches = CaffeineBuilder.newBuilder()
                .maximumSize(this.cacheSize)
                .initialCapacity(this.cacheSize)
                .build(this::loadEntry);
    }

    private Hierarchy loadEntry(String key) {
        return new Hierarchy();
    }

    private int getCacheEntrySize(int entrySize) {
        if (entrySize <= 0) {

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Set the cache size configuration to a positive integer
  2. Check where the value is parsed and add a default fallback for empty/unparseable values
  3. Validate configuration at startup before constructing the caches

Example fix

// before
int size = Integer.parseInt(props.getProperty("cache.size")); // "0"
HierarchyCaches c = new DefaultHierarchyCaches(size, entrySize);
// after
int size = Math.max(1, Integer.parseInt(props.getProperty("cache.size", "1024")));
HierarchyCaches c = new DefaultHierarchyCaches(size, entrySize);
Defensive patterns

Strategy: validation

Validate before calling

int size = Integer.parseInt(cfg.getProperty("cache.size", "1024"));
if (size <= 0) throw new IllegalArgumentException("cache.size must be > 0, got " + size);

Try / catch

try { caches = new DefaultHierarchyCaches(size, entrySize); } catch (IllegalArgumentException e) { log.error("bad cache config: {}", e.getMessage()); caches = new DefaultHierarchyCaches(1024, 1024); }

Prevention

When it happens

Trigger: Instantiating new DefaultHierarchyCaches(size, entrySize) with size = 0 or a negative value, typically from misconfigured profiler properties (e.g. profiler.jdbc.maxcachesize style settings).

Common situations: Config file sets a cache-size property to 0 or negative; property parsing yields 0 when a value is missing or unparseable and defaults are skipped.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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