Program: 80097
Project: 80097
Buggy source:
public void testReplication() throws Exception {
  cleanAllTestHosts();
  initEnvironment();
  if (runUnReplicated) {
    util.DEBUG("String_Node_Str");
    initMaster(masterServerHost,replicatedDb);
    startServer(masterJvmVersion,derbyVersion,masterServerHost,ALL_INTERFACES,masterServerPort,masterDatabasePath + FS + masterDbSubPath);
    runTest(replicationTest,jvmVersion,testClientHost,masterServerHost,masterServerPort,replicatedDb);
    stopServer(masterJvmVersion,derbyMasterVersion,masterServerHost,masterServerPort);
    util.DEBUG("String_Node_Str");
  }
  if (state.testPreStartedMasterServer())   return;
  initMaster(masterServerHost,replicatedDb);
  masterServer=startServer(masterJvmVersion,derbyMasterVersion,masterServerHost,ALL_INTERFACES,masterServerPort,masterDatabasePath + FS + masterDbSubPath);
  startOptionalLoad(masterPreRepl,masterDbSubPath,masterServerHost,masterServerPort);
  if (state.testPreStartedSlaveServer())   return;
  slaveServer=startServer(slaveJvmVersion,derbySlaveVersion,slaveServerHost,ALL_INTERFACES,slaveServerPort,slaveDatabasePath + FS + slaveDbSubPath);
  startServerMonitor(slaveServerHost);
  xFindServerPID(slaveServerHost,slaveServerPort);
  bootMasterDatabase(jvmVersion,masterDatabasePath + FS + masterDbSubPath,replicatedDb,masterServerHost,masterServerPort,null);
  startOptionalLoad(masterPostRepl,masterDbSubPath,masterServerHost,masterServerPort);
  startOptionalLoad(slavePreSlave,slaveDbSubPath,slaveServerHost,slaveServerPort);
  if (state.testPreInitSlave())   return;
  initSlave(slaveServerHost,jvmVersion,replicatedDb);
  if (state.testPreStartedSlave())   return;
  startSlave(jvmVersion,replicatedDb,slaveServerHost,slaveServerPort,slaveServerHost,slaveReplPort,testClientHost);
  if (state.testPreStartedMaster())   return;
  startMaster(jvmVersion,replicatedDb,masterServerHost,masterServerPort,masterServerHost,slaveServerPort,slaveServerHost,slaveReplPort);
  startOptionalLoad(masterPostSlave,masterDbSubPath,masterServerHost,masterServerPort);
  startOptionalLoad(slavePostSlave,slaveDbSubPath,slaveServerHost,slaveServerPort);
  if (state.testPostStartedMasterAndSlave())   return;
  runTest(replicationTest,jvmVersion,testClientHost,masterServerHost,masterServerPort,replicatedDb);
  if (state.testPreStoppedMaster())   return;
  if (state.testPreStoppedMasterServer())   return;
  if (state.testPreStoppedSlave())   return;
  failOver(jvmVersion,masterDatabasePath,masterDbSubPath,replicatedDb,masterServerHost,masterServerPort,testClientHost);
  connectPing(slaveDatabasePath + FS + slaveDbSubPath+ FS+ replicatedDb,slaveServerHost,slaveServerPort,testClientHost);
  int slavePid=xFindServerPID(slaveServerHost,slaveServerPort);
  if (slavePid == -1) {
    util.DEBUG("String_Node_Str");
    slaveServer=startServer(jvmVersion,derbyVersion,slaveServerHost,ALL_INTERFACES,slaveServerPort,slaveDatabasePath + FS + slaveDbSubPath);
  }
 else {
    if (true) {
      util.DEBUG("String_Node_Str");
    }
 else {
      util.DEBUG("String_Node_Str");
      restartServer(jvmVersion,derbyVersion,slaveServerHost,ALL_INTERFACES,slaveServerPort,slaveDatabasePath + FS + slaveDbSubPath);
    }
  }
  verifySlave();
  int masterPid=xFindServerPID(masterServerHost,masterServerPort);
  if (masterPid == -1) {
    util.DEBUG("String_Node_Str");
    masterServer=startServer(jvmVersion,derbyVersion,masterServerHost,ALL_INTERFACES,masterServerPort,masterDatabasePath + FS + masterDbSubPath);
  }
  verifyMaster();
  xFindServerPID(slaveServerHost,slaveServerPort);
  stopServer(jvmVersion,derbyVersion,slaveServerHost,slaveServerPort);
  if (state.testPostStoppedSlaveServer())   return;
  stopServer(jvmVersion,derbyVersion,masterServerHost,masterServerPort);
  masterPid=xFindServerPID(masterServerHost,masterServerPort);
  if (masterPid != -1) {
    util.DEBUG("String_Node_Str");
    killMaster(masterServerHost,masterServerPort);
  }
}

Fixed version (ground truth):
public void testReplication() throws Exception {
  cleanAllTestHosts();
  initEnvironment();
  if (runUnReplicated) {
    util.DEBUG("String_Node_Str");
    initMaster(masterServerHost,replicatedDb);
    startServer(masterJvmVersion,derbyVersion,masterServerHost,ALL_INTERFACES,masterServerPort,masterDbSubPath);
    runTest(replicationTest,jvmVersion,testClientHost,masterServerHost,masterServerPort,replicatedDb);
    stopServer(masterJvmVersion,derbyMasterVersion,masterServerHost,masterServerPort);
    util.DEBUG("String_Node_Str");
  }
  if (state.testPreStartedMasterServer())   return;
  initMaster(masterServerHost,replicatedDb);
  masterServer=startServer(masterJvmVersion,derbyMasterVersion,masterServerHost,ALL_INTERFACES,masterServerPort,masterDbSubPath);
  startOptionalLoad(masterPreRepl,masterDbSubPath,masterServerHost,masterServerPort);
  if (state.testPreStartedSlaveServer())   return;
  slaveServer=startServer(slaveJvmVersion,derbySlaveVersion,slaveServerHost,ALL_INTERFACES,slaveServerPort,slaveDbSubPath);
  startServerMonitor(slaveServerHost);
  xFindServerPID(slaveServerHost,slaveServerPort);
  bootMasterDatabase(jvmVersion,masterDatabasePath + FS + masterDbSubPath,replicatedDb,masterServerHost,masterServerPort,null);
  startOptionalLoad(masterPostRepl,masterDbSubPath,masterServerHost,masterServerPort);
  startOptionalLoad(slavePreSlave,slaveDbSubPath,slaveServerHost,slaveServerPort);
  if (state.testPreInitSlave())   return;
  initSlave(slaveServerHost,jvmVersion,replicatedDb);
  if (state.testPreStartedSlave())   return;
  startSlave(jvmVersion,replicatedDb,slaveServerHost,slaveServerPort,slaveServerHost,slaveReplPort,testClientHost);
  if (state.testPreStartedMaster())   return;
  startMaster(jvmVersion,replicatedDb,masterServerHost,masterServerPort,masterServerHost,slaveServerPort,slaveServerHost,slaveReplPort);
  startOptionalLoad(masterPostSlave,masterDbSubPath,masterServerHost,masterServerPort);
  startOptionalLoad(slavePostSlave,slaveDbSubPath,slaveServerHost,slaveServerPort);
  if (state.testPostStartedMasterAndSlave())   return;
  runTest(replicationTest,jvmVersion,testClientHost,masterServerHost,masterServerPort,replicatedDb);
  if (state.testPreStoppedMaster())   return;
  if (state.testPreStoppedMasterServer())   return;
  if (state.testPreStoppedSlave())   return;
  failOver(jvmVersion,masterDatabasePath,masterDbSubPath,replicatedDb,masterServerHost,masterServerPort,testClientHost);
  connectPing(slaveDatabasePath + FS + slaveDbSubPath+ FS+ replicatedDb,slaveServerHost,slaveServerPort,testClientHost);
  int slavePid=xFindServerPID(slaveServerHost,slaveServerPort);
  if (slavePid == -1) {
    util.DEBUG("String_Node_Str");
    slaveServer=startServer(jvmVersion,derbyVersion,slaveServerHost,ALL_INTERFACES,slaveServerPort,slaveDbSubPath);
  }
 else {
    if (true) {
      util.DEBUG("String_Node_Str");
    }
 else {
      util.DEBUG("String_Node_Str");
      restartServer(jvmVersion,derbyVersion,slaveServerHost,ALL_INTERFACES,slaveServerPort,slaveDbSubPath);
    }
  }
  verifySlave();
  int masterPid=xFindServerPID(masterServerHost,masterServerPort);
  if (masterPid == -1) {
    util.DEBUG("String_Node_Str");
    masterServer=startServer(jvmVersion,derbyVersion,masterServerHost,ALL_INTERFACES,masterServerPort,masterDbSubPath);
  }
  verifyMaster();
  xFindServerPID(slaveServerHost,slaveServerPort);
  stopServer(jvmVersion,derbyVersion,slaveServerHost,slaveServerPort);
  if (state.testPostStoppedSlaveServer())   return;
  stopServer(jvmVersion,derbyVersion,masterServerHost,masterServerPort);
  masterPid=xFindServerPID(masterServerHost,masterServerPort);
  if (masterPid != -1) {
    util.DEBUG("String_Node_Str");
    killMaster(masterServerHost,masterServerPort);
  }
}