Program: 154728
Project: 154728
Buggy source:
public void process(WatchedEvent event){
  try {
    String path=event.getPath();
    msgLog.logMessage(this + "String_Node_Str" + new Date()+ "String_Node_Str"+ event+ "String_Node_Str"+ path+ "String_Node_Str");
    if (path == null && event.getState() == Watcher.Event.KeeperState.Expired) {
      keeperState=KeeperState.Expired;
      if (zooKeeper != null) {
        try {
          zooKeeper.close();
        }
 catch (        InterruptedException e) {
          e.printStackTrace();
          Thread.interrupted();
        }
      }
      zooKeeper=instantiateZooKeeper();
    }
 else     if (path == null && event.getState() == Watcher.Event.KeeperState.SyncConnected) {
      Pair<Master,Machine> masterBeforeIWrite=getMasterFromZooKeeper(false);
      msgLog.logMessage("String_Node_Str" + masterBeforeIWrite);
      sequenceNr=setup();
      msgLog.logMessage("String_Node_Str" + sequenceNr);
      keeperState=KeeperState.SyncConnected;
      Pair<Master,Machine> masterAfterIWrote=getMasterFromZooKeeper(false);
      msgLog.logMessage("String_Node_Str" + masterAfterIWrote);
      int masterId=masterAfterIWrote.other().getMachineId();
      setDataChangeWatcher(MASTER_NOTIFY_CHILD,masterId);
      receiver.newMaster(masterAfterIWrote,new Exception());
    }
 else     if (path == null && event.getState() == Watcher.Event.KeeperState.Disconnected) {
      keeperState=KeeperState.Disconnected;
    }
 else     if (event.getType() == Watcher.Event.EventType.NodeDataChanged) {
      Pair<Master,Machine> currentMaster=getMasterFromZooKeeper(true);
      if (path.contains(MASTER_NOTIFY_CHILD)) {
        setDataChangeWatcher(MASTER_NOTIFY_CHILD,-1);
        if (currentMaster.other().getMachineId() == machineId) {
          receiver.newMaster(currentMaster,new Exception());
        }
      }
 else       if (path.contains(MASTER_REBOUND_CHILD)) {
        setDataChangeWatcher(MASTER_REBOUND_CHILD,-1);
        if (currentMaster.other().getMachineId() != machineId) {
          receiver.newMaster(currentMaster,new Exception());
        }
      }
 else {
        msgLog.logMessage("String_Node_Str" + path);
      }
    }
  }
 catch (  RuntimeException e) {
    msgLog.logMessage("String_Node_Str",e);
    e.printStackTrace();
    throw e;
  }
}

Fixed version (ground truth):
public void process(WatchedEvent event){
  try {
    String path=event.getPath();
    msgLog.logMessage(this + "String_Node_Str" + new Date()+ "String_Node_Str"+ event+ "String_Node_Str"+ path+ "String_Node_Str");
    if (path == null && event.getState() == Watcher.Event.KeeperState.Expired) {
      keeperState=KeeperState.Expired;
      if (zooKeeper != null) {
        try {
          zooKeeper.close();
        }
 catch (        InterruptedException e) {
          e.printStackTrace();
          Thread.interrupted();
        }
      }
      zooKeeper=instantiateZooKeeper();
    }
 else     if (path == null && event.getState() == Watcher.Event.KeeperState.SyncConnected) {
      long newSessionId=zooKeeper.getSessionId();
      if (newSessionId != sessionId) {
        Pair<Master,Machine> masterBeforeIWrite=getMasterFromZooKeeper(false);
        msgLog.logMessage("String_Node_Str" + masterBeforeIWrite);
        sequenceNr=setup();
        msgLog.logMessage("String_Node_Str" + sequenceNr + "String_Node_Str"+ newSessionId);
        keeperState=KeeperState.SyncConnected;
        Pair<Master,Machine> masterAfterIWrote=getMasterFromZooKeeper(false);
        msgLog.logMessage("String_Node_Str" + masterAfterIWrote);
        int masterId=masterAfterIWrote.other().getMachineId();
        setDataChangeWatcher(MASTER_NOTIFY_CHILD,masterId);
        receiver.newMaster(masterAfterIWrote,new Exception());
        sessionId=newSessionId;
      }
 else {
        msgLog.logMessage("String_Node_Str" + sessionId);
        keeperState=KeeperState.SyncConnected;
      }
    }
 else     if (path == null && event.getState() == Watcher.Event.KeeperState.Disconnected) {
      keeperState=KeeperState.Disconnected;
    }
 else     if (event.getType() == Watcher.Event.EventType.NodeDataChanged) {
      Pair<Master,Machine> currentMaster=getMasterFromZooKeeper(true);
      if (path.contains(MASTER_NOTIFY_CHILD)) {
        setDataChangeWatcher(MASTER_NOTIFY_CHILD,-1);
        if (currentMaster.other().getMachineId() == machineId) {
          receiver.newMaster(currentMaster,new Exception());
        }
      }
 else       if (path.contains(MASTER_REBOUND_CHILD)) {
        setDataChangeWatcher(MASTER_REBOUND_CHILD,-1);
        if (currentMaster.other().getMachineId() != machineId) {
          receiver.newMaster(currentMaster,new Exception());
        }
      }
 else {
        msgLog.logMessage("String_Node_Str" + path);
      }
    }
  }
 catch (  RuntimeException e) {
    msgLog.logMessage("String_Node_Str",e);
    e.printStackTrace();
    throw e;
  }
}