Program: 87267
Project: 87267
Buggy source:
/** 
 * Do actions for the state we are now in.  Essentially, we're always one state ahead of the participants thus we process the result of a Collect in the BEGIN state which means we expect Last or OldRound and in SUCCESS state we expect ACCEPT or OLDROUND
 * @todo Check Last messages to compute minimum low and maximum high watermarks, then use them to perform recovery
 * @todo Ensure during recovery that BEGIN doesn't screw up the sequence number - perhaps during recovery prevent BEGIN from doingsequence number increments
 * @todo Handle all cases in SUCCEESS e.g. we don't properly process/wait for all Acks
 */
private void process(){
switch (_stage) {
case ABORT:
case EXIT:
{
      _logger.info("String_Node_Str" + Long.toHexString(_seqNum) + "String_Node_Str"+ (_stage == EXIT));
      if (_stage == EXIT) {
        _transport.send(new Ack(_seqNum),_clientAddress);
      }
 else {
        _transport.send(new Fail(_seqNum,_reason),_clientAddress);
      }
      _membership.dispose();
      signalListeners();
      return;
    }
case COLLECT:
{
    _value=_clientPost.getValue();
    if (isLeader()) {
      _logger.info("String_Node_Str");
      _stage=BEGIN;
      process();
    }
 else {
      collect();
      _stage=BEGIN;
    }
    break;
  }
case BEGIN:
{
  byte[] myValue=_value;
  if (!isLeader()) {
    long myMaxRound=0;
    Iterator<PaxosMessage> myMessages=_messages.iterator();
    while (myMessages.hasNext()) {
      PaxosMessage myMessage=myMessages.next();
      if (myMessage.getType() == Operations.OLDROUND) {
        oldRound(myMessage);
        return;
      }
 else {
        Last myLast=(Last)myMessage;
        if (myLast.getRndNumber() > myMaxRound) {
          myMaxRound=myLast.getRndNumber();
          myValue=myLast.getValue();
        }
      }
    }
  }
  amLeader();
  _value=myValue;
  if (_seqNum == LogStorage.EMPTY_LOG) {
    _seqNum=-1;
  }
  begin();
  _stage=SUCCESS;
  break;
}
case SUCCESS:
{
int myAcceptCount=0;
Iterator<PaxosMessage> myMessages=_messages.iterator();
while (myMessages.hasNext()) {
  PaxosMessage myMessage=myMessages.next();
  if (myMessage.getType() == Operations.OLDROUND) {
    oldRound(myMessage);
    return;
  }
 else {
    myAcceptCount++;
  }
}
if (myAcceptCount >= _membership.getMajority()) {
  success();
  _stage=EXIT;
}
 else {
  begin();
  _stage=SUCCESS;
}
break;
}
default :
throw new RuntimeException("String_Node_Str" + _stage);
}
}

Fixed version (ground truth):
/** 
 * Do actions for the state we are now in.  Essentially, we're always one state ahead of the participants thus we process the result of a Collect in the BEGIN state which means we expect Last or OldRound and in SUCCESS state we expect ACCEPT or OLDROUND
 * @todo Check Last messages to compute minimum low and maximum high watermarks, then use them to perform recovery
 * @todo Ensure during recovery that BEGIN doesn't screw up the sequence number - perhaps during recovery prevent BEGIN from doingsequence number increments
 * @todo Handle all cases in SUCCEESS e.g. we don't properly process/wait for all Acks
 */
private void process(){
switch (_stage) {
case ABORT:
case EXIT:
{
      _logger.info("String_Node_Str" + Long.toHexString(_seqNum) + "String_Node_Str"+ (_stage == EXIT));
      if (_stage == EXIT) {
        _transport.send(new Ack(_seqNum),_clientAddress);
      }
 else {
        _transport.send(new Fail(_seqNum,_reason),_clientAddress);
      }
      _membership.dispose();
      signalListeners();
      return;
    }
case COLLECT:
{
    _value=_clientPost.getValue();
    if (_seqNum == LogStorage.EMPTY_LOG) {
      _seqNum=0;
    }
 else {
      ++_seqNum;
    }
    if (isLeader()) {
      _logger.info("String_Node_Str");
      _stage=BEGIN;
      process();
    }
 else {
      collect();
      _stage=BEGIN;
    }
    break;
  }
case BEGIN:
{
  byte[] myValue=_value;
  if (!isLeader()) {
    long myMaxRound=0;
    Iterator<PaxosMessage> myMessages=_messages.iterator();
    while (myMessages.hasNext()) {
      PaxosMessage myMessage=myMessages.next();
      if (myMessage.getType() == Operations.OLDROUND) {
        oldRound(myMessage);
        return;
      }
 else {
        Last myLast=(Last)myMessage;
        if (myLast.getRndNumber() > myMaxRound) {
          myMaxRound=myLast.getRndNumber();
          myValue=myLast.getValue();
        }
      }
    }
  }
  amLeader();
  _value=myValue;
  begin();
  _stage=SUCCESS;
  break;
}
case SUCCESS:
{
int myAcceptCount=0;
Iterator<PaxosMessage> myMessages=_messages.iterator();
while (myMessages.hasNext()) {
  PaxosMessage myMessage=myMessages.next();
  if (myMessage.getType() == Operations.OLDROUND) {
    oldRound(myMessage);
    return;
  }
 else {
    myAcceptCount++;
  }
}
if (myAcceptCount >= _membership.getMajority()) {
  success();
  _stage=EXIT;
}
 else {
  begin();
  _stage=SUCCESS;
}
break;
}
default :
throw new RuntimeException("String_Node_Str" + _stage);
}
}