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

size: array.length

Error message

size:${size} array.length:${array.length}

What it means

IndexOutOfBoundsException guard in UnsafeArrayCollection.add: the collection's fixed backing array (allocated at maxSize) cannot hold another element. Note the guard itself is buggy — it compares array.length < size instead of size >= array.length, so it fires one element late and then writes out of bounds.

Solutions

  1. Size the UnsafeArrayCollection with enough headroom for the maximum concurrent additions
  2. Replace with a growable collection or use the bounded executor that owns it with correct capacity
  3. Fix the guard to 'size >= array.length' so overflow is detected before the write
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/concurrent/executor/UnsafeArrayCollection.java:38 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/concurrent/executor/UnsafeArrayCollection.java:38

import java.util.Arrays;
import java.util.Iterator;

/**
 * @author emeroad
 */
class UnsafeArrayCollection<E> extends AbstractCollection<E> {

    private int size = 0;
    private final Object[] array;

    public UnsafeArrayCollection(int maxSize) {
        this.array = new Object[maxSize];
    }

    @Override
    public boolean add(E o) {
        if (array.length < size) {
            throw new IndexOutOfBoundsException("size:" + this.size + " array.length:" + array.length);
        }
        // do not check array bound
        array[size++] = o;
        return true;
    }

    @Override
    public void clear() {
        // Need to clear values in array. It costs CPU but prevent memory leak.
        for (int i = 0; i < size; i++) {
            this.array[i] = null;
        }
        this.size = 0;
    }

    @Override
    public boolean isEmpty() {
        return this.size == 0;

View on GitHub (pinned to 744c3d3075)