{"record":{"id":"b7b06d7c94176efb","repo":"pinpoint-apm/pinpoint","slug":"size-size-array-length-array-length","errorCode":null,"errorMessage":"size:${size} array.length:${array.length}","messagePattern":"size:(.+?) array\\.length:(.+?)","errorType":"exception","errorClass":"java.lang.IndexOutOfBoundsException","httpStatus":null,"severity":"error","filePath":"commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/concurrent/executor/UnsafeArrayCollection.java","lineNumber":38,"sourceCode":"import java.util.Arrays;\nimport java.util.Iterator;\n\n/**\n * @author emeroad\n */\nclass UnsafeArrayCollection<E> extends AbstractCollection<E> {\n\n    private int size = 0;\n    private final Object[] array;\n\n    public UnsafeArrayCollection(int maxSize) {\n        this.array = new Object[maxSize];\n    }\n\n    @Override\n    public boolean add(E o) {\n        if (array.length < size) {\n            throw new IndexOutOfBoundsException(\"size:\" + this.size + \" array.length:\" + array.length);\n        }\n        // do not check array bound\n        array[size++] = o;\n        return true;\n    }\n\n    @Override\n    public void clear() {\n        // Need to clear values in array. It costs CPU but prevent memory leak.\n        for (int i = 0; i < size; i++) {\n            this.array[i] = null;\n        }\n        this.size = 0;\n    }\n\n    @Override\n    public boolean isEmpty() {\n        return this.size == 0;","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/concurrent/executor/UnsafeArrayCollection.java#L20-L56","documentation":"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.","triggerScenarios":"Thrown at commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/concurrent/executor/UnsafeArrayCollection.java:38 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Size the UnsafeArrayCollection with enough headroom for the maximum concurrent additions","Replace with a growable collection or use the bounded executor that owns it with correct capacity","Fix the guard to 'size >= array.length' so overflow is detected before the write"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}