Program: 98387
Project: 98387
Buggy source:
/** 
 * inserts point into and splits the target node
 * @param splittingLeaf
 * @param newPoint
 * @throws AssertionError when the target node doesnot have any children
 */
private void splitLeaf(RStarLeaf splittingLeaf,SpatialPoint newPoint) throws AssertionError {
  ArrayList<Long> childPointers=splittingLeaf.childPointers;
  if (childPointers.size() <= 0) {
    throw new AssertionError();
  }
  ArrayList<SpatialPoint> children=new ArrayList<SpatialPoint>(childPointers.size());
  for (  long childId : childPointers) {
    PointDTO dto=storage.loadPoint(childId);
    children.add(new SpatialPoint(dto));
  }
  children.add(newPoint);
  int splitAxis=chooseLeafSplitAxis(children);
  int splitPoint=chooseLeafSplitpoint(children,splitAxis);
  Object[] sorting=children.toArray();
  final SpatialComparator comp=new SpatialComparator(splitAxis,bestSortOrder);
  Arrays.sort(sorting,comp);
  splittingLeaf.loadedChildren=new ArrayList<SpatialPoint>();
  splittingLeaf.childPointers=new ArrayList<Long>();
  RStarLeaf newChild=new RStarLeaf(dimension);
  for (int i=0; i < sorting.length; i++) {
    SpatialPoint spatialPoint=(SpatialPoint)sorting[i];
    if (i < splitPoint) {
      if (spatialPoint == newPoint) {
        splittingLeaf.loadedChildren.add(spatialPoint);
      }
 else {
        splittingLeaf.childPointers.add(childPointers.get(children.indexOf(spatialPoint)));
      }
    }
 else {
      if (spatialPoint == newPoint) {
        newChild.loadedChildren.add(spatialPoint);
      }
 else {
        newChild.childPointers.add(childPointers.get(children.indexOf(spatialPoint)));
      }
    }
  }
  storage.saveNode(splittingLeaf);
  if (splittingLeaf.getNodeId() == rootPointer) {
    splitRoot(newChild);
  }
 else {
    newChild.setParentId(splittingLeaf.getParentId());
    insert(splittingLeaf.getParentId(),newChild);
  }
}

Fixed version (ground truth):
/** 
 * inserts point into and splits the target node
 * @param splittingLeaf
 * @param newPoint
 * @throws AssertionError when the target node doesnot have any children
 */
private void splitLeaf(RStarLeaf splittingLeaf,SpatialPoint newPoint) throws AssertionError {
  ArrayList<Long> childPointers=splittingLeaf.childPointers;
  if (childPointers.size() <= 0) {
    throw new AssertionError();
  }
  ArrayList<SpatialPoint> children=new ArrayList<SpatialPoint>(childPointers.size());
  for (  long childId : childPointers) {
    PointDTO dto=storage.loadPoint(childId);
    children.add(new SpatialPoint(dto));
  }
  children.add(newPoint);
  int splitAxis=chooseLeafSplitAxis(children);
  int splitPoint=chooseLeafSplitpoint(children,splitAxis);
  Object[] sorting=children.toArray();
  final SpatialComparator comp=new SpatialComparator(splitAxis,bestSortOrder);
  sort(sorting,comp);
  splittingLeaf.loadedChildren=new ArrayList<SpatialPoint>();
  splittingLeaf.childPointers=new ArrayList<Long>();
  RStarLeaf newChild=new RStarLeaf(dimension);
  HyperRectangle newMbr1=new HyperRectangle(dimension);
  HyperRectangle newMbr2=new HyperRectangle(dimension);
  for (int i=0; i < sorting.length; i++) {
    SpatialPoint spatialPoint=(SpatialPoint)sorting[i];
    if (i < splitPoint) {
      if (spatialPoint == newPoint) {
        splittingLeaf.loadedChildren.add(spatialPoint);
      }
 else {
        splittingLeaf.childPointers.add(childPointers.get(children.indexOf(spatialPoint)));
      }
      newMbr1.update(spatialPoint);
    }
 else {
      if (spatialPoint == newPoint) {
        newChild.loadedChildren.add(spatialPoint);
      }
 else {
        newChild.childPointers.add(childPointers.get(children.indexOf(spatialPoint)));
      }
      newMbr2.update(spatialPoint);
    }
  }
  splittingLeaf.mbr=newMbr1;
  newChild.mbr=newMbr2;
  storage.saveNode(splittingLeaf);
  if (splittingLeaf.getNodeId() == rootPointer) {
    root=splittingLeaf;
    splitRoot(newChild);
  }
 else {
    newChild.setParentId(splittingLeaf.getParentId());
    insert(splittingLeaf.getParentId(),newChild);
  }
}