Program: 184159
Project: 184159
Buggy source:
/** 
 * Allows someone to consume pixels from this polygon. There are some edge cases where the requested number of points my not have actually been consumed if the expansion outward from the selected start point encounter problems. I'm trying to remove this annoyance, but for now that means that this method should be called in a loop, checking if the desired area was received.
 * @param amountOfArea the number of pixels desired. If this is greater than the size of this polygon, all polygon pixels are returned and this poly will deregister itself from the area
 * @return all of the points that can be consumed, up toMath.min(amountOfArea,size). The caller should check the size to see if it got what it requested
 */
public Collection<Point> consumeArea(int amountOfArea,Point startPoint){
  log.entering(className,"String_Node_Str",new Object[]{amountOfArea,startPoint});
  if (amountOfArea >= getArea()) {
    mRegionManager.removeRegion(this);
    log.exiting(className,"String_Node_Str","String_Node_Str");
    return mPoints;
  }
  List<Point> consumablePoints=new ArrayList<Point>(amountOfArea + 8);
  if (isConsumable(startPoint.x,startPoint.y,consumablePoints)) {
    log.finest("String_Node_Str");
    consumablePoints.add(startPoint);
  }
 else {
    log.info("String_Node_Str");
    log.exiting(className,"String_Node_Str");
    return consumablePoints;
  }
  int i=0;
  int lastIterationListSize=0;
  do {
    Point cur=null;
    try {
      cur=consumablePoints.get(i);
    }
 catch (    IndexOutOfBoundsException ide) {
      if (lastIterationListSize == consumablePoints.size()) {
        mPoints.removeAll(consumablePoints);
        return consumablePoints;
      }
      log.finest("String_Node_Str");
      i=0;
      cur=consumablePoints.get(i);
      lastIterationListSize=consumablePoints.size();
    }
    log.finest("String_Node_Str" + cur + "String_Node_Str");
    if (isConsumable(cur.x,cur.y - 1,consumablePoints))     consumablePoints.add(new Point(cur.x,cur.y - 1));
    if (isConsumable(cur.x + 1,cur.y,consumablePoints))     consumablePoints.add(new Point(cur.x + 1,cur.y));
    if (isConsumable(cur.x,cur.y + 1,consumablePoints))     consumablePoints.add(new Point(cur.x,cur.y + 1));
    if (isConsumable(cur.x - 1,cur.y,consumablePoints))     consumablePoints.add(new Point(cur.x - 1,cur.y));
    ++i;
  }
 while (consumablePoints.size() < amountOfArea);
  while (consumablePoints.size() != amountOfArea)   consumablePoints.remove(amountOfArea);
  mPoints.removeAll(consumablePoints);
  log.exiting(className,"String_Node_Str");
  return consumablePoints;
}

Fixed version (ground truth):
/** 
 * Allows someone to consume pixels from this polygon. There are some edge cases where the requested number of points my not have actually been consumed if the expansion outward from the selected start point encounter problems. I'm trying to remove this annoyance, but for now that means that this method should be called in a loop, checking if the desired area was received.
 * @param amountOfArea the number of pixels desired. If this is greater than the size of this polygon, all polygon pixels are returned and this poly will deregister itself from the area
 * @return all of the points that can be consumed, up toMath.min(amountOfArea,size). The caller should check the size to see if it got what it requested
 */
public Collection<Point> consumeArea(int amountOfArea,Point startPoint){
  log.entering(className,"String_Node_Str",new Object[]{amountOfArea,startPoint});
  if (amountOfArea >= getArea()) {
    mRegionManager.removeRegion(this);
    log.exiting(className,"String_Node_Str","String_Node_Str");
    return mPoints;
  }
  List<Point> consumablePoints=new ArrayList<Point>(amountOfArea + 8);
  if (isConsumable(startPoint.x,startPoint.y,consumablePoints)) {
    log.finest("String_Node_Str");
    consumablePoints.add(startPoint);
  }
 else {
    log.info("String_Node_Str");
    log.exiting(className,"String_Node_Str");
    return consumablePoints;
  }
  int i=0;
  int lastIterationListSize=0;
  while (consumablePoints.size() < amountOfArea) {
    Point cur=null;
    try {
      cur=consumablePoints.get(i);
    }
 catch (    IndexOutOfBoundsException ide) {
      if (lastIterationListSize == consumablePoints.size()) {
        mPoints.removeAll(consumablePoints);
        assert(isContigious());
        return consumablePoints;
      }
      log.finest("String_Node_Str");
      i=0;
      cur=consumablePoints.get(i);
      lastIterationListSize=consumablePoints.size();
    }
    log.finest("String_Node_Str" + cur + "String_Node_Str");
    if (isConsumable(cur.x,cur.y - 1,consumablePoints))     consumablePoints.add(new Point(cur.x,cur.y - 1));
    if (isConsumable(cur.x + 1,cur.y,consumablePoints))     consumablePoints.add(new Point(cur.x + 1,cur.y));
    if (isConsumable(cur.x,cur.y + 1,consumablePoints))     consumablePoints.add(new Point(cur.x,cur.y + 1));
    if (isConsumable(cur.x - 1,cur.y,consumablePoints))     consumablePoints.add(new Point(cur.x - 1,cur.y));
    ++i;
  }
  while (consumablePoints.size() != amountOfArea)   consumablePoints.remove(amountOfArea);
  mPoints.removeAll(consumablePoints);
  log.exiting(className,"String_Node_Str");
  return consumablePoints;
}