Program: 46131
Project: 46131
Buggy source:
/** 
 * Return the space that encloses this point, if the space does not exist, create it
 * @param position
 * @return
 */
public Iterable<Space> getEnclosingSpace(BoundingVolume volume){
  ArrayList retList=new ArrayList();
  Vector3f point=volume.getCenter();
  float xf=((point.x + SPACE_SIZE) / (SPACE_SIZE * 2));
  float yf=((point.y + SPACE_SIZE) / (SPACE_SIZE * 2));
  float zf=((point.z + SPACE_SIZE) / (SPACE_SIZE * 2));
  int x, y, z;
  if (xf > 0)   x=(int)Math.floor(xf);
 else   x=(int)Math.ceil(xf);
  if (yf > 0)   y=(int)Math.floor(yf);
 else   y=(int)Math.ceil(yf);
  if (zf > 0)   z=(int)Math.floor(zf);
 else   z=(int)Math.ceil(zf);
  Space sp=getEnclosingSpaceImpl(x,y,z);
  if (sp == null) {
    sp=createSpace(x,y,z);
  }
  retList.add(sp);
  int xStep;
  int yStep;
  int zStep;
  if (volume instanceof BoundingBox) {
    xStep=1 + (int)(((BoundingBox)volume).xExtent / (SPACE_SIZE));
    yStep=1 + (int)(((BoundingBox)volume).yExtent / (SPACE_SIZE));
    zStep=1 + (int)(((BoundingBox)volume).zExtent / (SPACE_SIZE));
  }
 else   if (volume instanceof BoundingSphere) {
    xStep=yStep=zStep=1 + (int)(((BoundingSphere)volume).getRadius() / (SPACE_SIZE));
  }
 else   throw new RuntimeException("String_Node_Str" + volume.getClass().getName());
  yStep=0;
  for (int xs=-xStep; xs <= xStep; xs++) {
    for (int ys=-yStep; ys <= yStep; ys++) {
      for (int zs=-zStep; zs <= zStep; zs++) {
        sp=getEnclosingSpaceImpl(x + xs,y + ys,z + zs);
        if (sp == null) {
          sp=createSpace(x + xs,y + ys,z + zs);
        }
        if (sp.getWorldBounds().intersects(volume)) {
          retList.add(sp);
        }
 else {
        }
      }
    }
  }
  return retList;
}

Fixed version (ground truth):
/** 
 * Return the space that encloses this point, if the space does not exist, create it
 * @param position
 * @return
 */
public Iterable<Space> getEnclosingSpace(BoundingVolume volume){
  ArrayList retList=new ArrayList();
  Vector3f point=volume.getCenter();
  float xf=((point.x + SPACE_SIZE) / (SPACE_SIZE * 2));
  float yf=((point.y + SPACE_SIZE) / (SPACE_SIZE * 2));
  float zf=((point.z + SPACE_SIZE) / (SPACE_SIZE * 2));
  int x, y, z;
  if (xf > 0)   x=(int)Math.floor(xf);
 else   x=(int)Math.ceil(xf);
  if (yf > 0)   y=(int)Math.floor(yf);
 else   y=(int)Math.ceil(yf);
  if (zf > 0)   z=(int)Math.floor(zf);
 else   z=(int)Math.ceil(zf);
  Space sp=getEnclosingSpaceImpl(x,y,z);
  if (sp == null) {
    sp=createSpace(x,y,z);
  }
  retList.add(sp);
  int xStep;
  int yStep;
  int zStep;
  if (volume instanceof BoundingBox) {
    xStep=1 + (int)(((BoundingBox)volume).xExtent / (SPACE_SIZE));
    yStep=1 + (int)(((BoundingBox)volume).yExtent / (SPACE_SIZE));
    zStep=1 + (int)(((BoundingBox)volume).zExtent / (SPACE_SIZE));
  }
 else   if (volume instanceof BoundingSphere) {
    xStep=yStep=zStep=1 + (int)(((BoundingSphere)volume).getRadius() / (SPACE_SIZE));
  }
 else   throw new RuntimeException("String_Node_Str" + volume.getClass().getName());
  for (int xs=-xStep; xs <= xStep; xs++) {
    for (int ys=-yStep; ys <= yStep; ys++) {
      for (int zs=-zStep; zs <= zStep; zs++) {
        sp=getEnclosingSpaceImpl(x + xs,y + ys,z + zs);
        if (sp == null) {
          sp=createSpace(x + xs,y + ys,z + zs);
        }
        if (sp.getWorldBounds().intersects(volume)) {
          retList.add(sp);
        }
 else {
        }
      }
    }
  }
  return retList;
}