pinpoint-apm/pinpoint · error · IllegalArgumentException

key

Error message

key

What it means

ConcurrentPool.get(K key) rejects null keys with IllegalArgumentException because null keys cannot be safely stored or looked up in the underlying ConcurrentHashMap and would defeat the factory-based lazy creation. Thrown at the very start of get().

Source

Thrown at agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/scope/ConcurrentPool.java:40

import java.util.concurrent.ConcurrentMap;

/**
 * @author Woonduk Kang(emeroad)
 */
public class ConcurrentPool<K, V> implements Pool<K, V> {

    private final ConcurrentMap<K, V> pool = new ConcurrentHashMap<K, V>();

    private final PoolObjectFactory<K, V> objectFactory;

    public ConcurrentPool(PoolObjectFactory<K, V> objectFactory) {
        this.objectFactory = Objects.requireNonNull(objectFactory, "objectFactory");
    }

    @Override
    public V get(K key) {
        if (key == null) {
            throw new IllegalArgumentException("key");
        }

        final V alreadyExist = this.pool.get(key);
        if (alreadyExist != null) {
            return alreadyExist;
        }

        final V newValue = this.objectFactory.create(key);
        final V oldValue = this.pool.putIfAbsent(key, newValue);
        if (oldValue != null) {
            return oldValue;
        }
        return newValue;
    }


}

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Check the key for null before calling get() and skip caching or throw a more descriptive error upstream
  2. Trace where the key comes from and fix the producer of the null value
  3. Use an explicit sentinel/Optional instead of null as a key

Example fix

// before
V value = pool.get(keyMaybeNull);
// after
if (keyMaybeNull == null) {
    throw new IllegalArgumentException("cache key must not be null");
}
V value = pool.get(keyMaybeNull);
Defensive patterns

Strategy: validation

Validate before calling

if (key == null) { throw new IllegalArgumentException("key must not be null before pool.get"); }

Type guard

boolean validKey = (key != null);

Try / catch

try { V v = pool.get(key); } catch (IllegalArgumentException e) { logger.warn("null pool key"); }

Prevention

When it happens

Trigger: Calling pool.get(null) — typically when a caller derives the key (e.g. class name, method ID) from an upstream value that was itself null.

Common situations: Instrumentation code caching objects keyed by a classloader/class name that is unexpectedly null during bootstrap or unloaded classes.

Related errors


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