Program: 87257
Project: 87257
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 Increment round number via heartbeats every so often - see note below about jittering collects.
 */
private void process(){
switch (_state) {
case ABORT:
{
      assert(_queue.size() != 0);
      _logger.info(this + "String_Node_Str" + _event,new RuntimeException());
      _messages.clear();
      if (_membership != null)       _membership.dispose();
      while (_queue.size() > 0) {
        _al.signal(new Event(_event.getResult(),_event.getSeqNum(),_queue.remove(0)));
      }
      return;
    }
case EXIT:
{
    assert(_queue.size() != 0);
    _logger.info(this + "String_Node_Str" + _event);
    _messages.clear();
    _queue.remove(0);
    if (_membership != null)     _membership.dispose();
    if (_queue.size() > 0) {
      _logger.info(this + "String_Node_Str" + _queue.get(0));
      _state=SUBMITTED;
      process();
    }
 else {
      _heartbeatAlarm=new TimerTask(){
        public void run(){
          _logger.info(this + "String_Node_Str" + System.currentTimeMillis());
          submit(AcceptorLearner.HEARTBEAT);
        }
      }
;
      _watchdog.schedule(_heartbeatAlarm,calculateLeaderRefresh());
    }
    return;
  }
case SUBMITTED:
{
  assert(_queue.size() != 0);
  _tries=0;
  _membership=_detector.getMembers(this);
  _logger.info(this + "String_Node_Str" + _membership.getSize()+ "String_Node_Str");
  _state=COLLECT;
  process();
  break;
}
case COLLECT:
{
assert(_queue.size() != 0);
if (_heartbeatAlarm != null) _heartbeatAlarm.cancel();
Collect myLastCollect=_al.getLastCollect();
if (myLastCollect.isInitial()) {
  _logger.info(this + "String_Node_Str");
  _rndNumber=myLastCollect.getRndNumber() + 1;
}
 else {
  InetSocketAddress myOtherLeader=myLastCollect.getNodeId();
  boolean isUs=myOtherLeader.equals(_transport.getLocalAddress());
  if (!isUs) {
    _logger.info(this + "String_Node_Str");
    if (_detector.isLive(myOtherLeader)) {
      _logger.info(this + "String_Node_Str");
      error(Event.Reason.OTHER_LEADER,myOtherLeader);
      return;
    }
 else {
      _logger.info(this + "String_Node_Str");
      if (_rndNumber <= myLastCollect.getRndNumber())       _rndNumber=myLastCollect.getRndNumber() + 1;
    }
  }
}
if (_seqNum == AcceptorLearner.UNKNOWN_SEQ) _seqNum=0;
 else _seqNum=_seqNum + 1;
_state=BEGIN;
emit(new Collect(_seqNum,_rndNumber,_transport.getLocalAddress()));
break;
}
case BEGIN:
{
assert(_queue.size() != 0);
long myMaxProposal=-1;
ConsolidatedValue myValue=null;
for (PaxosMessage m : _messages) {
Last myLast=(Last)m;
if (!myLast.getConsolidatedValue().equals(LogStorage.NO_VALUE)) {
  if (myLast.getRndNumber() > myMaxProposal)   myValue=myLast.getConsolidatedValue();
}
}
if ((myValue != null) && (!myValue.equals(_queue.get(0)))) _queue.add(myValue);
_state=SUCCESS;
emit(new Begin(_seqNum,_rndNumber,_queue.get(0),_transport.getLocalAddress()));
break;
}
case SUCCESS:
{
assert(_queue.size() != 0);
if (_messages.size() >= _detector.getMajority()) {
_state=COMMITTED;
emit(new Success(_seqNum,_rndNumber,_queue.get(0),_transport.getLocalAddress()));
}
 else {
emit(new Begin(_seqNum,_rndNumber,_queue.get(0),_transport.getLocalAddress()));
}
break;
}
case COMMITTED:
{
assert(_queue.size() != 0);
if (_messages.size() >= _detector.getMajority()) {
successful(Event.Reason.DECISION,null);
}
 else {
emit(new Success(_seqNum,_rndNumber,_queue.get(0),_transport.getLocalAddress()));
}
break;
}
default :
throw new RuntimeException("String_Node_Str" + _state);
}
}

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 Increment round number via heartbeats every so often - see note below about jittering collects.
 */
private void process(){
switch (_state) {
case ABORT:
{
      assert(_queue.size() != 0);
      _logger.info(this + "String_Node_Str" + _event,new RuntimeException());
      _messages.clear();
      if (_membership != null)       _membership.dispose();
      while (_queue.size() > 0) {
        _al.signal(new Event(_event.getResult(),_event.getSeqNum(),_queue.remove(0)));
      }
      return;
    }
case EXIT:
{
    assert(_queue.size() != 0);
    _logger.info(this + "String_Node_Str" + _event);
    _messages.clear();
    _queue.remove(0);
    if (_membership != null)     _membership.dispose();
    if (_queue.size() > 0) {
      _logger.info(this + "String_Node_Str" + _queue.get(0));
      _state=SUBMITTED;
      process();
    }
 else {
      _heartbeatAlarm=new TimerTask(){
        public void run(){
          _logger.info(this + "String_Node_Str" + System.currentTimeMillis());
          submit(AcceptorLearner.HEARTBEAT);
        }
      }
;
      _watchdog.schedule(_heartbeatAlarm,calculateLeaderRefresh());
    }
    return;
  }
case SUBMITTED:
{
  assert(_queue.size() != 0);
  _tries=0;
  _membership=_detector.getMembers(this);
  _logger.info(this + "String_Node_Str" + _membership.getSize()+ "String_Node_Str");
  _state=COLLECT;
  process();
  break;
}
case COLLECT:
{
assert(_queue.size() != 0);
if (_heartbeatAlarm != null) _heartbeatAlarm.cancel();
Collect myLastCollect=_al.getLastCollect();
if (myLastCollect.isInitial()) {
  _logger.info(this + "String_Node_Str");
  _rndNumber=myLastCollect.getRndNumber() + 1;
}
 else {
  InetSocketAddress myOtherLeader=myLastCollect.getNodeId();
  boolean isUs=myOtherLeader.equals(_transport.getLocalAddress());
  if (!isUs) {
    _logger.info(this + "String_Node_Str");
    if (_detector.isLive(myOtherLeader)) {
      _logger.info(this + "String_Node_Str");
      error(Event.Reason.OTHER_LEADER,myOtherLeader);
      return;
    }
 else {
      _logger.info(this + "String_Node_Str");
      if (_rndNumber <= myLastCollect.getRndNumber())       _rndNumber=myLastCollect.getRndNumber() + 1;
    }
  }
}
if (_seqNum == AcceptorLearner.UNKNOWN_SEQ) _seqNum=0;
 else _seqNum=_seqNum + 1;
_state=BEGIN;
emit(new Collect(_seqNum,_rndNumber,_transport.getLocalAddress()));
break;
}
case BEGIN:
{
assert(_queue.size() != 0);
long myMaxProposal=-1;
ConsolidatedValue myValue=null;
for (PaxosMessage m : _messages) {
Last myLast=(Last)m;
if (!myLast.getConsolidatedValue().equals(LogStorage.NO_VALUE)) {
  if (myLast.getRndNumber() > myMaxProposal) {
    myValue=myLast.getConsolidatedValue();
    myMaxProposal=myLast.getRndNumber();
  }
}
}
if ((myValue != null) && (!myValue.equals(_queue.get(0)))) _queue.add(myValue);
_state=SUCCESS;
emit(new Begin(_seqNum,_rndNumber,_queue.get(0),_transport.getLocalAddress()));
break;
}
case SUCCESS:
{
assert(_queue.size() != 0);
if (_messages.size() >= _detector.getMajority()) {
_state=COMMITTED;
emit(new Success(_seqNum,_rndNumber,_queue.get(0),_transport.getLocalAddress()));
}
 else {
emit(new Begin(_seqNum,_rndNumber,_queue.get(0),_transport.getLocalAddress()));
}
break;
}
case COMMITTED:
{
assert(_queue.size() != 0);
if (_messages.size() >= _detector.getMajority()) {
successful(Event.Reason.DECISION,null);
}
 else {
emit(new Success(_seqNum,_rndNumber,_queue.get(0),_transport.getLocalAddress()));
}
break;
}
default :
throw new RuntimeException("String_Node_Str" + _state);
}
}