Program: 15037
Project: 15037
Buggy source:
public void setState(final VmState newState,SystemState.Reason reason,String... extra){
  this.updateWatch.split();
  if (this.updateWatch.getSplitTime() > 1000 * 60 * 60) {
    this.store();
    this.updateWatch.unsplit();
  }
 else {
    this.updateWatch.unsplit();
  }
  this.resetStopWatch();
  VmState oldState=this.runtimeState.getReference();
  if (VmState.SHUTTING_DOWN.equals(newState) && VmState.SHUTTING_DOWN.equals(oldState) && Reason.USER_TERMINATED.equals(reason)) {
    VmInstances.cleanUp(this);
    if (!this.reasonDetails.contains(SEND_USER_TERMINATE)) {
      this.addReasonDetail(SEND_USER_TERMINATE);
    }
  }
 else   if (VmState.STOPPING.equals(newState) && VmState.STOPPING.equals(oldState) && Reason.USER_STOPPED.equals(reason)) {
    VmInstances.cleanUp(this);
    if (!this.reasonDetails.contains(SEND_USER_STOP)) {
      this.addReasonDetail(SEND_USER_STOP);
    }
  }
 else   if (VmState.TERMINATED.equals(newState) && VmState.TERMINATED.equals(oldState)) {
    VmInstances.getInstance().deregister(this.getName());
    try {
      Transactions.delete(this);
    }
 catch (    ExecutionException ex) {
      LOG.error(ex,ex);
    }
  }
 else   if (!this.getRuntimeState().equals(newState)) {
    if (Reason.APPEND.equals(reason)) {
      reason=this.reason;
    }
    this.addReasonDetail(extra);
    LOG.info(String.format("String_Node_Str",this.getInstanceId(),this.getRuntimeState(),newState));
    this.reason=reason;
    if (this.runtimeState.isMarked() && VmState.PENDING.equals(this.getRuntimeState())) {
      if (VmState.SHUTTING_DOWN.equals(newState) || VmState.PENDING.equals(newState)) {
        this.runtimeState.set(newState,true);
      }
 else {
        this.runtimeState.set(newState,false);
      }
    }
 else     if (this.runtimeState.isMarked() && VmState.SHUTTING_DOWN.equals(this.getRuntimeState())) {
      LOG.debug("String_Node_Str" + oldState + "String_Node_Str"+ this.getRuntimeState());
    }
 else     if (!this.runtimeState.isMarked()) {
      if (oldState.ordinal() <= VmState.RUNNING.ordinal() && newState.ordinal() > VmState.RUNNING.ordinal()) {
        this.runtimeState.set(newState,false);
        VmInstances.cleanUp(this);
      }
 else       if (VmState.PENDING.equals(oldState) && VmState.RUNNING.equals(newState)) {
        this.runtimeState.set(newState,false);
      }
 else       if (VmState.TERMINATED.equals(newState) && oldState.ordinal() <= VmState.RUNNING.ordinal()) {
        this.runtimeState.set(newState,false);
        VmInstances.getInstance().disable(this.getName());
        VmInstances.cleanUp(this);
      }
 else       if (VmState.TERMINATED.equals(newState) && oldState.ordinal() > VmState.RUNNING.ordinal()) {
        this.runtimeState.set(newState,false);
        VmInstances.getInstance().disable(this.getName());
      }
 else       if (oldState.ordinal() > VmState.RUNNING.ordinal() && newState.ordinal() <= VmState.RUNNING.ordinal()) {
        this.runtimeState.set(oldState,false);
        VmInstances.cleanUp(this);
      }
 else       if (newState.ordinal() > oldState.ordinal()) {
        this.runtimeState.set(newState,false);
      }
      this.store();
    }
 else {
      LOG.debug("String_Node_Str" + oldState + "String_Node_Str"+ this.getRuntimeState());
    }
    if (!this.getRuntimeState().equals(oldState)) {
      EventRecord.caller(VmInstance.class,EventType.VM_STATE,this.instanceId,this.getOwner(),this.runtimeState.getReference().name(),this.launchTime);
    }
  }
}

Fixed version (ground truth):
public void setState(final VmState newState,SystemState.Reason reason,String... extra){
  this.updateWatch.split();
  if (this.updateWatch.getSplitTime() > 1000 * 60 * 60) {
    this.store();
    this.updateWatch.unsplit();
  }
 else {
    this.updateWatch.unsplit();
  }
  this.resetStopWatch();
  VmState oldState=this.runtimeState.getReference();
  if (VmState.SHUTTING_DOWN.equals(newState) && VmState.SHUTTING_DOWN.equals(oldState) && Reason.USER_TERMINATED.equals(reason)) {
    VmInstances.cleanUp(this);
    if (!this.reasonDetails.contains(SEND_USER_TERMINATE)) {
      this.addReasonDetail(SEND_USER_TERMINATE);
    }
  }
 else   if (VmState.STOPPING.equals(newState) && VmState.STOPPING.equals(oldState) && Reason.USER_STOPPED.equals(reason)) {
    VmInstances.cleanUp(this);
    if (!this.reasonDetails.contains(SEND_USER_STOP)) {
      this.addReasonDetail(SEND_USER_STOP);
    }
  }
 else   if (VmState.TERMINATED.equals(newState) && VmState.TERMINATED.equals(oldState)) {
    VmInstances.getInstance().deregister(this.getName());
    try {
      Transactions.delete(this);
    }
 catch (    Exception ex) {
      LOG.error(ex,ex);
    }
  }
 else   if (!this.getRuntimeState().equals(newState)) {
    if (Reason.APPEND.equals(reason)) {
      reason=this.reason;
    }
    this.addReasonDetail(extra);
    LOG.info(String.format("String_Node_Str",this.getInstanceId(),this.getRuntimeState(),newState));
    this.reason=reason;
    if (this.runtimeState.isMarked() && VmState.PENDING.equals(this.getRuntimeState())) {
      if (VmState.SHUTTING_DOWN.equals(newState) || VmState.PENDING.equals(newState)) {
        this.runtimeState.set(newState,true);
      }
 else {
        this.runtimeState.set(newState,false);
      }
    }
 else     if (this.runtimeState.isMarked() && VmState.SHUTTING_DOWN.equals(this.getRuntimeState())) {
      LOG.debug("String_Node_Str" + oldState + "String_Node_Str"+ this.getRuntimeState());
    }
 else     if (!this.runtimeState.isMarked()) {
      if (oldState.ordinal() <= VmState.RUNNING.ordinal() && newState.ordinal() > VmState.RUNNING.ordinal()) {
        this.runtimeState.set(newState,false);
        VmInstances.cleanUp(this);
      }
 else       if (VmState.PENDING.equals(oldState) && VmState.RUNNING.equals(newState)) {
        this.runtimeState.set(newState,false);
      }
 else       if (VmState.TERMINATED.equals(newState) && oldState.ordinal() <= VmState.RUNNING.ordinal()) {
        this.runtimeState.set(newState,false);
        VmInstances.getInstance().disable(this.getName());
        VmInstances.cleanUp(this);
      }
 else       if (VmState.TERMINATED.equals(newState) && oldState.ordinal() > VmState.RUNNING.ordinal()) {
        this.runtimeState.set(newState,false);
        VmInstances.getInstance().disable(this.getName());
      }
 else       if (oldState.ordinal() > VmState.RUNNING.ordinal() && newState.ordinal() <= VmState.RUNNING.ordinal()) {
        this.runtimeState.set(oldState,false);
        VmInstances.cleanUp(this);
      }
 else       if (newState.ordinal() > oldState.ordinal()) {
        this.runtimeState.set(newState,false);
      }
      this.store();
    }
 else {
      LOG.debug("String_Node_Str" + oldState + "String_Node_Str"+ this.getRuntimeState());
    }
    if (!this.getRuntimeState().equals(oldState)) {
      EventRecord.caller(VmInstance.class,EventType.VM_STATE,this.instanceId,this.getOwner(),this.runtimeState.getReference().name(),this.launchTime);
    }
  }
}