Program: 76079
Project: 76079
Buggy source:
/** 
 * Double the capacity of one of the queues with the smallest capacity belonging to a receiver on which a process is blocked while attempting to write. <p>Traverse through the list of receivers on which a process is blocked on a write and choose the one containing the queue with the smallest capacity. Double the capacity if the capacity is non-negative. In case the capacity is negative, set the capacity to 1. Unblock the process blocked on a write to the receiver containing this queue. Notify the thread corresponding to the blocked process to resume its execution and return.
 */
protected void _incrementLowestWriteCapacityPort(){
  PNQueueReceiver smallestCapacityQueue=null;
  int smallestCapacity=-1;
  Iterator receivers=_writeblockedQueues.iterator();
  while (receivers.hasNext()) {
    PNQueueReceiver queue=(PNQueueReceiver)receivers.next();
    if (smallestCapacity == -1) {
      smallestCapacityQueue=queue;
      smallestCapacity=queue.getCapacity();
    }
 else     if (smallestCapacity > queue.getCapacity()) {
      smallestCapacityQueue=queue;
      smallestCapacity=queue.getCapacity();
    }
  }
  try {
    if (smallestCapacityQueue.getCapacity() <= 0) {
      smallestCapacityQueue.setCapacity(1);
    }
 else {
      smallestCapacityQueue.setCapacity(smallestCapacityQueue.getCapacity() * 2);
    }
    _actorUnBlocked(smallestCapacityQueue);
    smallestCapacityQueue.setWritePending(false);
synchronized (smallestCapacityQueue) {
      smallestCapacityQueue.notifyAll();
    }
  }
 catch (  IllegalActionException e) {
    throw new InternalErrorException(e.toString());
  }
  return;
}

Fixed version (ground truth):
/** 
 * Double the capacity of one of the queues with the smallest capacity belonging to a receiver on which a process is blocked while attempting to write. <p>Traverse through the list of receivers on which a process is blocked on a write and choose the one containing the queue with the smallest capacity. Double the capacity if the capacity is non-negative. In case the capacity is negative, set the capacity to 1. Unblock the process blocked on a write to the receiver containing this queue. Notify the thread corresponding to the blocked process to resume its execution and return.
 */
protected void _incrementLowestWriteCapacityPort(){
  PNQueueReceiver smallestCapacityQueue=null;
  int smallestCapacity=-1;
  Iterator receivers=_writeblockedQueues.iterator();
  if (!receivers.hasNext()) {
    return;
  }
  while (receivers.hasNext()) {
    PNQueueReceiver queue=(PNQueueReceiver)receivers.next();
    if (smallestCapacity == -1) {
      smallestCapacityQueue=queue;
      smallestCapacity=queue.getCapacity();
    }
 else     if (smallestCapacity > queue.getCapacity()) {
      smallestCapacityQueue=queue;
      smallestCapacity=queue.getCapacity();
    }
  }
  try {
    if (smallestCapacityQueue.getCapacity() <= 0) {
      smallestCapacityQueue.setCapacity(1);
    }
 else {
      smallestCapacityQueue.setCapacity(smallestCapacityQueue.getCapacity() * 2);
    }
    _actorUnBlocked(smallestCapacityQueue);
    smallestCapacityQueue.setWritePending(false);
synchronized (smallestCapacityQueue) {
      smallestCapacityQueue.notifyAll();
    }
  }
 catch (  IllegalActionException e) {
    throw new InternalErrorException(e.toString());
  }
  return;
}