Program: 55691
Project: 55691
Buggy source:
/** 
 * Calculates the partitions. <br> The results can be accessed with the supplied getter methods.
 */
public void calculatePartitions(){
  for (int y=0; y < height; y++) {
    for (int x=0; x < width; x++) {
      int index=x + y * width;
      if (containing.get(index)) {
        if (blockingProvider.isBlocked(minX + x,minY + y)) {
          partitionsGrid[index]=BLOCKED_PARTITION;
          continue;
        }
        int westX=x + neighborX[0];
        int westY=y + neighborY[0];
        int northWestX=x + neighborX[1];
        int northWestY=y + neighborY[1];
        int northEastX=x + neighborX[2];
        int northEastY=y + neighborY[2];
        int partition=-1;
        int westPartition=-1;
        int northEastPartition=-1;
        if (containing.get(westX + westY * width)) {
          short currPartition=partitionsGrid[westX + westY * width];
          if (currPartition != BLOCKED_PARTITION) {
            westPartition=currPartition;
            partition=currPartition;
          }
        }
        if (containing.get(northWestX + northWestY * width)) {
          short currPartition=partitionsGrid[northWestX + northWestY * width];
          if (currPartition != BLOCKED_PARTITION) {
            partition=currPartition;
          }
        }
        if (containing.get(northEastX + northEastY * width)) {
          short currPartition=partitionsGrid[northEastX + northEastY * width];
          if (currPartition != BLOCKED_PARTITION) {
            northEastPartition=currPartition;
            partition=currPartition;
          }
        }
        if (westPartition != -1 && northEastPartition != -1 && partitions[westPartition] != partitions[northEastPartition]) {
          short newPartition=(short)Math.min(partitions[westPartition],partitions[northEastPartition]);
          partitions[westPartition]=newPartition;
          partitions[northEastPartition]=newPartition;
          partitionsGrid[index]=newPartition;
        }
 else         if (partition != -1) {
          partitionsGrid[index]=partitions[partition];
        }
 else {
          partitionsGrid[index]=createNewPartition(y,x);
        }
      }
    }
  }
  normalizePartitions();
}

Fixed version (ground truth):
/** 
 * Calculates the partitions. <br> The results can be accessed with the supplied getter methods.
 */
public void calculatePartitions(){
  for (int y=0; y < height; y++) {
    for (int x=0; x < width; x++) {
      int index=x + y * width;
      if (containing.get(index)) {
        if (blockingProvider.isBlocked(minX + x,minY + y)) {
          partitionsGrid[index]=BLOCKED_PARTITION;
          continue;
        }
        int westX=x + neighborX[0];
        int westY=y + neighborY[0];
        int northWestX=x + neighborX[1];
        int northWestY=y + neighborY[1];
        int northEastX=x + neighborX[2];
        int northEastY=y + neighborY[2];
        int partition=-1;
        int westPartition=-1;
        int northEastPartition=-1;
        if (containing.get(westX + westY * width)) {
          short currPartition=partitions[partitionsGrid[westX + westY * width]];
          if (currPartition != BLOCKED_PARTITION) {
            westPartition=currPartition;
            partition=currPartition;
          }
        }
        if (containing.get(northWestX + northWestY * width)) {
          short currPartition=partitions[partitionsGrid[northWestX + northWestY * width]];
          if (currPartition != BLOCKED_PARTITION) {
            partition=currPartition;
          }
        }
        if (containing.get(northEastX + northEastY * width)) {
          short currPartition=partitions[partitionsGrid[northEastX + northEastY * width]];
          if (currPartition != BLOCKED_PARTITION) {
            northEastPartition=currPartition;
            partition=currPartition;
          }
        }
        if (westPartition != -1 && northEastPartition != -1 && partitions[westPartition] != partitions[northEastPartition]) {
          short newPartition=(short)Math.min(partitions[westPartition],partitions[northEastPartition]);
          partitions[westPartition]=newPartition;
          partitions[northEastPartition]=newPartition;
          partitionsGrid[index]=newPartition;
        }
 else         if (partition != -1) {
          partitionsGrid[index]=partitions[partition];
        }
 else {
          partitionsGrid[index]=createNewPartition(y,x);
        }
      }
    }
  }
  normalizePartitions();
}