Program: 32882
Project: 32882
Buggy source:
/** 
 * Performs the action of the task. This method shall initially be called using a worker thread, which is not allowed to interact with the user interface. If it is ever necessary for this task to update the user interface before continuing, the task shall return REPEAT_ON_EVENT_DISPATCH_THREAD, and the doTask() method will be called again on the event dispatch thread. For this to work successfully, the task should keep track internally as to where it needs to resume work on the user interface. When user interface work is complete, if the task has additional background work to perform, it can return REPEAT_ON_WORKER_THREAD. This will call the method yet again, but using a worker thread as to not busy the user interface. If this task is cancelled, the thread.interrupt() method will be called. The task can check if it has been interrupted by calling the static method, Thread.interrupted(). If it is ever interrupted it should throw a InterruptedException. The task should clean up any necessary resources before throwing a InterruptedException, because the task shall not be run again. If at any point the task fails, it should throw an exception and the task will be stopped. The exception will be available to the user for their information as to why the task has stopped.
 */
public int doTask() throws InterruptedException, Exception ;

Fixed version (ground truth):
/** 
 * Performs the action of the task. This method shall initially be called using a worker thread, which is not allowed to interact with the user interface. If it is ever necessary for this task to update the user interface before continuing, the task shall return REPEAT_ON_EVENT_DISPATCH_THREAD, and the doTask() method will be called again on the event dispatch thread. For this to work successfully, the task should keep track internally as to where it needs to resume work on the user interface. When user interface work is complete, if the task has additional background work to perform, it can return REPEAT_ON_WORKER_THREAD. This will call the method yet again, but using a worker thread as to not busy the user interface. If this task is cancelled, the thread.interrupt() method will be called. The task can check if it has been interrupted by calling the static method, Thread.interrupted(). If it is ever interrupted it should throw a InterruptedException. The task should clean up any necessary resources before throwing a InterruptedException, because the task shall not be run again. If at any point the task fails, it should throw an exception and the task will be stopped. The exception will be available to the user for their information as to why the task has stopped. The call sequence parameter counts how many times the doTask method has been called in this single execution of the task. For example, if you have a task that performs background work and then GUI work and then background work, the first time this method is called it will be called with a background thread and the callSequence parameter will be 0. The second time the method is called it will be called on the event dispatch thread with a callSequence of 1. The third time the method is called it will be called on a background thread with a callSequence of 2. This can be used to separate your code into the segments that need to be executed on different threads by using if/then/else logic on the callSequence parameter.
 * @param callSequence the number of previous calls made to doTask() inis execution of this task.
 */
public int doTask(int callSequence) throws InterruptedException, Exception ;