pinpoint-apm/pinpoint · error · IllegalArgumentException

Illegal Load: +loadFactor

Error message

Illegal Load: +loadFactor

What it means

IntHashMap(int initialCapacity, float loadFactor) requires loadFactor > 0; a zero or negative load factor would break rehash growth. The constructor throws IllegalArgumentException ('Illegal Load: ...') to reject it, immediately after the capacity check.

Solutions

  1. Pass a positive load factor (standard: 0.75f)
  2. Validate the config float is > 0 before constructing
  3. Fall back to a default load factor when config is absent

Example fix

// before
float lf = Float.parseFloat(cfg.getProperty("map.loadfactor", "0")); // 0.0
IntHashMap map = new IntHashMap(16, lf); // throws
// after
float lf = Float.parseFloat(cfg.getProperty("map.loadfactor", "0.75"));
IntHashMap map = new IntHashMap(16, lf > 0 ? lf : 0.75f);
Defensive patterns

Strategy: validation

Validate before calling

if (loadFactor <= 0f) loadFactor = 0.75f;
IntHashMap map = new IntHashMap(initialCapacity, loadFactor);

Try / catch

try {
    map = new IntHashMap(initialCapacity, loadFactor);
} catch (IllegalArgumentException e) {
    logger.warn("IntHashMap load factor invalid: {}", e.getMessage());
    map = new IntHashMap(initialCapacity, 0.75f);
}

Prevention

When it happens

Trigger: Constructing IntHashMap with loadFactor <= 0, e.g. 0 from an unparsed float config or a negative tuning value.

Common situations: Load-factor property missing/blank so parsed to 0.0; copy-paste tuning values with wrong sign.

Related errors


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

Appendix: source

Thrown at commons/src/main/java/com/navercorp/pinpoint/common/util/apache/IntHashMap.java:126

        this(initialCapacity, 0.75f);
    }

    /**
     * <p>Constructs a new, empty hashtable with the specified initial
     * capacity and the specified load factor.</p>
     *
     * @param initialCapacity the initial capacity of the hashtable.
     * @param loadFactor the load factor of the hashtable.
     * @throws IllegalArgumentException  if the initial capacity is less
     *             than zero, or if the load factor is nonpositive.
     */
    public IntHashMap(int initialCapacity, float loadFactor) {
        super();
        if (initialCapacity < 0) {
            throw new IllegalArgumentException("Illegal Capacity: " + initialCapacity);
        }
        if (loadFactor <= 0) {
            throw new IllegalArgumentException("Illegal Load: " + loadFactor);
        }
        if (initialCapacity == 0) {
            initialCapacity = 1;
        }

        this.loadFactor = loadFactor;
        table = new Entry[initialCapacity];
        threshold = (int) (initialCapacity * loadFactor);
    }

    /**
     * <p>Returns the number of keys in this hashtable.</p>
     *
     * @return  the number of keys in this hashtable.
     */
    public int size() {
        return count;
    }

View on GitHub (pinned to 744c3d3075)