Program: 89327
Project: 89327
Buggy source:
protected HashMap<String,State> sync(){
  HashMap<String,State> changes=new HashMap<String,State>();
  HashMap<String,State> oldStates=null;
  try {
synchronized (_vms) {
      HashMap<String,State> newStates=getVmStates();
      oldStates=new HashMap<String,State>(_vms.size());
      oldStates.putAll(_vms);
      for (      final Map.Entry<String,State> entry : newStates.entrySet()) {
        final String vm=entry.getKey();
        State newState=entry.getValue();
        final State oldState=oldStates.remove(vm);
        if (s_logger.isTraceEnabled()) {
          s_logger.trace("String_Node_Str" + vm + "String_Node_Str"+ newState+ "String_Node_Str"+ (oldState != null ? oldState.toString() : "String_Node_Str"));
        }
        if (vm.startsWith("String_Node_Str")) {
          s_logger.debug("String_Node_Str");
          continue;
        }
        if (oldState == null) {
          _vms.put(vm,newState);
          s_logger.debug("String_Node_Str" + vm);
          changes.put(vm,newState);
        }
 else         if (oldState == State.Starting) {
          if (newState == State.Running) {
            _vms.put(vm,newState);
          }
 else           if (newState == State.Stopped) {
            s_logger.debug("String_Node_Str" + vm + "String_Node_Str");
          }
        }
 else         if (oldState == State.Migrating) {
          if (newState == State.Running) {
            s_logger.debug("String_Node_Str" + vm);
            _vms.put(vm,newState);
          }
        }
 else         if (oldState == State.Stopping) {
          if (newState == State.Stopped) {
            _vms.put(vm,newState);
          }
 else           if (newState == State.Running) {
            s_logger.debug("String_Node_Str" + vm + "String_Node_Str");
          }
        }
 else         if (oldState != newState) {
          _vms.put(vm,newState);
          if (newState == State.Stopped) {
          }
          changes.put(vm,newState);
        }
      }
      for (      final Map.Entry<String,State> entry : oldStates.entrySet()) {
        final String vm=entry.getKey();
        final State oldState=entry.getValue();
        if (isVmInCluster(vm)) {
          if (s_logger.isDebugEnabled()) {
            s_logger.debug("String_Node_Str" + vm + "String_Node_Str");
          }
          _vms.remove(vm);
          continue;
        }
        if (s_logger.isDebugEnabled()) {
          s_logger.debug("String_Node_Str" + vm + "String_Node_Str");
        }
        if (oldState == State.Stopping) {
          s_logger.debug("String_Node_Str" + vm + "String_Node_Str");
          _vms.remove(vm);
        }
 else         if (oldState == State.Starting) {
          s_logger.debug("String_Node_Str" + vm + "String_Node_Str");
        }
 else         if (oldState == State.Stopped) {
          _vms.remove(vm);
        }
 else         if (oldState == State.Migrating) {
          s_logger.debug("String_Node_Str" + vm + "String_Node_Str");
        }
 else {
          State state=State.Stopped;
          changes.put(entry.getKey(),state);
        }
      }
    }
  }
 catch (  Throwable e) {
    if (e instanceof RemoteException) {
      s_logger.warn("String_Node_Str");
      invalidateServiceContext();
    }
    s_logger.error("String_Node_Str" + VmwareHelper.getExceptionMessage(e));
    return null;
  }
  return changes;
}

Fixed version (ground truth):
protected HashMap<String,State> sync(){
  HashMap<String,State> changes=new HashMap<String,State>();
  HashMap<String,State> oldStates=null;
  try {
synchronized (_vms) {
      HashMap<String,State> newStates=getVmStates();
      oldStates=new HashMap<String,State>(_vms.size());
      oldStates.putAll(_vms);
      for (      final Map.Entry<String,State> entry : newStates.entrySet()) {
        final String vm=entry.getKey();
        State newState=entry.getValue();
        final State oldState=oldStates.remove(vm);
        if (s_logger.isTraceEnabled()) {
          s_logger.trace("String_Node_Str" + vm + "String_Node_Str"+ newState+ "String_Node_Str"+ (oldState != null ? oldState.toString() : "String_Node_Str"));
        }
        if (vm.startsWith("String_Node_Str")) {
          s_logger.debug("String_Node_Str");
          continue;
        }
        if (oldState == null) {
          _vms.put(vm,newState);
          s_logger.debug("String_Node_Str" + vm);
          changes.put(vm,newState);
        }
 else         if (oldState == State.Starting) {
          if (newState == State.Running) {
            _vms.put(vm,newState);
          }
 else           if (newState == State.Stopped) {
            s_logger.debug("String_Node_Str" + vm + "String_Node_Str");
          }
        }
 else         if (oldState == State.Migrating) {
          if (newState == State.Running) {
            s_logger.debug("String_Node_Str" + vm);
            _vms.put(vm,newState);
          }
        }
 else         if (oldState == State.Stopping) {
          if (newState == State.Stopped) {
            _vms.put(vm,newState);
          }
 else           if (newState == State.Running) {
            s_logger.debug("String_Node_Str" + vm + "String_Node_Str");
          }
        }
 else         if (oldState != newState) {
          _vms.put(vm,newState);
          if (newState == State.Stopped) {
          }
          changes.put(vm,newState);
        }
      }
      for (      final Map.Entry<String,State> entry : oldStates.entrySet()) {
        final String vm=entry.getKey();
        final State oldState=entry.getValue();
        if (isVmInCluster(vm)) {
          if (s_logger.isDebugEnabled()) {
            s_logger.debug("String_Node_Str" + vm + "String_Node_Str");
          }
          if (oldState != State.Starting && oldState != State.Migrating) {
            s_logger.debug("String_Node_Str" + vm + "String_Node_Str");
            _vms.remove(vm);
          }
 else {
            s_logger.debug("String_Node_Str" + vm + "String_Node_Str"+ vm+ "String_Node_Str"+ oldState);
          }
          continue;
        }
        if (s_logger.isDebugEnabled()) {
          s_logger.debug("String_Node_Str" + vm + "String_Node_Str");
        }
        if (oldState == State.Stopping) {
          s_logger.debug("String_Node_Str" + vm + "String_Node_Str");
          _vms.remove(vm);
        }
 else         if (oldState == State.Starting) {
          s_logger.debug("String_Node_Str" + vm + "String_Node_Str");
        }
 else         if (oldState == State.Stopped) {
          _vms.remove(vm);
        }
 else         if (oldState == State.Migrating) {
          s_logger.debug("String_Node_Str" + vm + "String_Node_Str");
        }
 else {
          State state=State.Stopped;
          changes.put(entry.getKey(),state);
        }
      }
    }
  }
 catch (  Throwable e) {
    if (e instanceof RemoteException) {
      s_logger.warn("String_Node_Str");
      invalidateServiceContext();
    }
    s_logger.error("String_Node_Str" + VmwareHelper.getExceptionMessage(e));
    return null;
  }
  return changes;
}