Program: 24197
Project: 24197
Buggy source:
@Override public ScriptPair call() throws Exception {
  try {
    if (abortScheduled) {
      return new ScriptPair();
    }
    controller.connect();
    PrepareCommand prepare=new PrepareCommand();
    prepare.setNames(names);
    prepare.setOverriddenScriptProperties(overridenScriptProperties);
    controller.writeCommand(prepare);
    boolean abortWritten=false;
    String expectedScript=null;
    while (true) {
      try {
        CommandEvent event=controller.readEvent(200,MILLISECONDS);
switch (event.getKind()) {
case PREPARED:
          PreparedEvent prepared=(PreparedEvent)event;
        expectedScript=prepared.getScript();
      for (      String barrier : prepared.getBarriers()) {
        barriers.put(barrier,new CountDownLatch(1));
      }
    latch.notifyPrepared();
  latch.awaitStartable();
if (abortScheduled && !abortWritten) {
  sendAbortCommand();
  abortWritten=true;
}
 else {
  StartCommand start=new StartCommand();
  controller.writeCommand(start);
}
break;
case STARTED:
break;
case NOTIFIED:
NotifiedEvent notifiedEvent=(NotifiedEvent)event;
String barrier=notifiedEvent.getBarrier();
CountDownLatch notifiedLatch=barriers.get(barrier);
notifiedLatch.countDown();
break;
case ERROR:
ErrorEvent error=(ErrorEvent)event;
throw new SpecificationException(format("String_Node_Str",error.getSummary(),error.getDescription()));
case FINISHED:
FinishedEvent finished=(FinishedEvent)event;
String observedScript=finished.getScript();
return new ScriptPair(expectedScript,observedScript);
default :
throw new IllegalArgumentException("String_Node_Str" + event.getKind());
}
}
 catch (SocketTimeoutException e) {
if (abortScheduled && !abortWritten) {
sendAbortCommand();
abortWritten=true;
}
if (Thread.interrupted()) {
throw new InterruptedException();
}
}
}
}
 catch (ConnectException e) {
Exception exception=new Exception("String_Node_Str",e);
exception.fillInStackTrace();
latch.notifyException(exception);
throw e;
}
catch (Exception e) {
latch.notifyException(e);
throw e;
}
 finally {
latch.notifyFinished();
}
}

Fixed version (ground truth):
@Override public ScriptPair call() throws Exception {
  try {
    if (abortScheduled) {
      return new ScriptPair();
    }
    controller.connect();
    PrepareCommand prepare=new PrepareCommand();
    prepare.setNames(names);
    prepare.setOverriddenScriptProperties(overridenScriptProperties);
    controller.writeCommand(prepare);
    boolean abortWritten=false;
    String expectedScript=null;
    String observedScript=null;
    boolean finishedReceived=false;
    while (true) {
      try {
        CommandEvent event=controller.readEvent(200,MILLISECONDS);
switch (event.getKind()) {
case PREPARED:
          PreparedEvent prepared=(PreparedEvent)event;
        expectedScript=prepared.getScript();
      for (      String barrier : prepared.getBarriers()) {
        barriers.put(barrier,new CountDownLatch(1));
      }
    latch.notifyPrepared();
  latch.awaitStartable();
if (abortScheduled && !abortWritten) {
  sendAbortCommand();
  abortWritten=true;
}
 else {
  StartCommand start=new StartCommand();
  controller.writeCommand(start);
}
break;
case STARTED:
break;
case NOTIFIED:
NotifiedEvent notifiedEvent=(NotifiedEvent)event;
String barrier=notifiedEvent.getBarrier();
CountDownLatch notifiedLatch=barriers.get(barrier);
notifiedLatch.countDown();
break;
case ERROR:
ErrorEvent error=(ErrorEvent)event;
throw new SpecificationException(format("String_Node_Str",error.getSummary(),error.getDescription()));
case FINISHED:
FinishedEvent finished=(FinishedEvent)event;
observedScript=finished.getScript();
finishedReceived=true;
break;
default :
throw new IllegalArgumentException("String_Node_Str" + event.getKind());
}
}
 catch (SocketTimeoutException e) {
if (finishedReceived) return new ScriptPair(expectedScript,observedScript);
if (abortScheduled && !abortWritten) {
sendAbortCommand();
abortWritten=true;
}
if (Thread.interrupted()) {
throw new InterruptedException();
}
}
}
}
 catch (ConnectException e) {
Exception exception=new Exception("String_Node_Str",e);
exception.fillInStackTrace();
latch.notifyException(exception);
throw e;
}
catch (Exception e) {
latch.notifyException(e);
throw e;
}
 finally {
latch.notifyFinished();
}
}