Program: 11553
Project: 11553
Buggy source:
/** 
 * Adds multiple tracks containing series of (x,y) positions to be painter. The positions of a single track are connected by lines. dataX[0] is an array containing the x coordinates of the positions in track id 0. dataX[0][0] is the x coordinate of point id 0 in track id 0. The ids are used when making spatial or temporal queries on this painter.
 * @param dataX x coordinate data for all points in all tracks
 * @param dataY y coordinate data for all points in all tracks
 */
public void setData(float[][] dataX,float[][] dataY){
  this.dataBufferLock.lock();
  try {
    lineCount=Math.min(dataX.length,dataY.length);
    totalPointCount=0;
    for (int trackId=0; trackId < lineCount; trackId++) {
      int pointCount=Math.min(dataX[trackId].length,dataY[trackId].length);
      totalPointCount+=pointCount;
    }
    if (dataBuffer == null || dataBuffer.rewind().capacity() < totalPointCount * 2) {
      this.dataBuffer=Buffers.newDirectFloatBuffer(totalPointCount * 2);
    }
    if (sizeBuffer == null || sizeBuffer.rewind().capacity() < lineCount) {
      this.sizeBuffer=Buffers.newDirectIntBuffer(lineCount);
    }
    if (offsetBuffer == null || offsetBuffer.rewind().capacity() < lineCount) {
      this.offsetBuffer=Buffers.newDirectIntBuffer(lineCount);
    }
    int pointCount=0;
    for (int trackId=0; trackId < lineCount; trackId++) {
      float[] trackX=dataX[trackId];
      float[] trackY=dataY[trackId];
      int trackLength=Math.min(dataX[trackId].length,dataY[trackId].length);
      this.offsetBuffer.put(pointCount);
      this.sizeBuffer.put(trackLength);
      pointCount+=trackLength;
      for (int i=0; i < trackLength; i++) {
        this.dataBuffer.put(trackX[i]).put(trackY[i]);
      }
    }
    pointCount=0;
    if (this.enableSpatialIndex) {
      this.spatialIndex=new QuadTreeXys<IdXy>(QUAD_TREE_BIN_MAX);
      for (int trackId=0; trackId < lineCount; trackId++) {
        float[] trackX=dataX[trackId];
        float[] trackY=dataY[trackId];
        int trackLength=Math.min(dataX[trackId].length,dataY[trackId].length);
        for (int i=0; i < trackLength; i++) {
          this.spatialIndex.add(new IdXy(pointCount++,trackX[i],trackY[i]));
        }
      }
    }
    this.newData=true;
  }
  finally {
    this.dataBufferLock.unlock();
  }
}

Fixed version (ground truth):
/** 
 * Adds multiple tracks containing series of (x,y) positions to be painter. The positions of a single track are connected by lines. dataX[0] is an array containing the x coordinates of the positions in track id 0. dataX[0][0] is the x coordinate of point id 0 in track id 0. The ids are used when making spatial or temporal queries on this painter.
 * @param dataX x coordinate data for all points in all tracks
 * @param dataY y coordinate data for all points in all tracks
 */
public void setData(float[][] dataX,float[][] dataY){
  this.dataBufferLock.lock();
  try {
    lineCount=Math.min(dataX.length,dataY.length);
    totalPointCount=0;
    for (int trackId=0; trackId < lineCount; trackId++) {
      int pointCount=Math.min(dataX[trackId].length,dataY[trackId].length);
      totalPointCount+=pointCount;
    }
    System.out.println(totalPointCount);
    if (dataBuffer == null || dataBuffer.rewind().capacity() < totalPointCount * 2) {
      this.dataBuffer=Buffers.newDirectFloatBuffer(totalPointCount * 2);
    }
    if (sizeBuffer == null || sizeBuffer.rewind().capacity() < lineCount) {
      this.sizeBuffer=Buffers.newDirectIntBuffer(lineCount);
    }
    if (offsetBuffer == null || offsetBuffer.rewind().capacity() < lineCount) {
      this.offsetBuffer=Buffers.newDirectIntBuffer(lineCount);
    }
    int pointCount=0;
    for (int trackId=0; trackId < lineCount; trackId++) {
      float[] trackX=dataX[trackId];
      float[] trackY=dataY[trackId];
      int trackLength=Math.min(dataX[trackId].length,dataY[trackId].length);
      this.offsetBuffer.put(pointCount);
      this.sizeBuffer.put(trackLength);
      pointCount+=trackLength;
      for (int i=0; i < trackLength; i++) {
        this.dataBuffer.put(trackX[i]).put(trackY[i]);
      }
    }
    pointCount=0;
    if (this.enableSpatialIndex) {
      this.spatialIndex=new QuadTreeXys<IdXy>(QUAD_TREE_BIN_MAX);
      for (int trackId=0; trackId < lineCount; trackId++) {
        float[] trackX=dataX[trackId];
        float[] trackY=dataY[trackId];
        int trackLength=Math.min(dataX[trackId].length,dataY[trackId].length);
        for (int i=0; i < trackLength; i++) {
          this.spatialIndex.add(new IdXy(pointCount++,trackX[i],trackY[i]));
        }
      }
    }
    this.newData=true;
  }
  finally {
    this.dataBufferLock.unlock();
  }
}