Program: 106112
Project: 106112
Buggy source:
protected Answer copySnapshot(DataObject srcData,DataObject destData){
  String value=configDao.getValue(Config.BackupSnapshotWait.toString());
  int _backupsnapshotwait=NumbersUtil.parseInt(value,Integer.parseInt(Config.BackupSnapshotWait.getDefaultValue()));
  DataObject cacheData=null;
  Answer answer=null;
  try {
    if (needCacheStorage(srcData,destData)) {
      Scope selectedScope=pickCacheScopeForCopy(srcData,destData);
      cacheData=cacheMgr.getCacheObject(srcData,selectedScope);
      CopyCommand cmd=new CopyCommand(srcData.getTO(),destData.getTO(),_backupsnapshotwait,_mgmtServer.getExecuteInSequence());
      cmd.setCacheTO(cacheData.getTO());
      EndPoint ep=selector.select(srcData,destData);
      if (ep == null) {
        String errMsg="String_Node_Str";
        s_logger.error(errMsg);
        answer=new Answer(cmd,false,errMsg);
      }
 else {
        answer=ep.sendMessage(cmd);
      }
    }
 else {
      CopyCommand cmd=new CopyCommand(srcData.getTO(),destData.getTO(),_backupsnapshotwait,_mgmtServer.getExecuteInSequence());
      EndPoint ep=selector.select(srcData,destData);
      if (ep == null) {
        String errMsg="String_Node_Str";
        s_logger.error(errMsg);
        answer=new Answer(cmd,false,errMsg);
      }
 else {
        answer=ep.sendMessage(cmd);
      }
    }
    if (answer == null || !answer.getResult()) {
      if (cacheData != null) {
        cacheMgr.deleteCacheObject(cacheData);
      }
    }
    return answer;
  }
 catch (  Exception e) {
    s_logger.debug("String_Node_Str" + e.toString());
    if (cacheData != null) {
      cacheMgr.deleteCacheObject(cacheData);
    }
    throw new CloudRuntimeException(e.toString());
  }
}

Fixed version (ground truth):
protected Answer copySnapshot(DataObject srcData,DataObject destData){
  String value=configDao.getValue(Config.BackupSnapshotWait.toString());
  int _backupsnapshotwait=NumbersUtil.parseInt(value,Integer.parseInt(Config.BackupSnapshotWait.getDefaultValue()));
  DataObject cacheData=null;
  Answer answer=null;
  try {
    if (needCacheStorage(srcData,destData)) {
      Scope selectedScope=pickCacheScopeForCopy(srcData,destData);
      cacheData=cacheMgr.getCacheObject(srcData,selectedScope);
      CopyCommand cmd=new CopyCommand(srcData.getTO(),destData.getTO(),_backupsnapshotwait,VirtualMachineManager.ExecuteInSequence.value());
      cmd.setCacheTO(cacheData.getTO());
      EndPoint ep=selector.select(srcData,destData);
      if (ep == null) {
        String errMsg="String_Node_Str";
        s_logger.error(errMsg);
        answer=new Answer(cmd,false,errMsg);
      }
 else {
        answer=ep.sendMessage(cmd);
      }
    }
 else {
      CopyCommand cmd=new CopyCommand(srcData.getTO(),destData.getTO(),_backupsnapshotwait,VirtualMachineManager.ExecuteInSequence.value());
      EndPoint ep=selector.select(srcData,destData);
      if (ep == null) {
        String errMsg="String_Node_Str";
        s_logger.error(errMsg);
        answer=new Answer(cmd,false,errMsg);
      }
 else {
        answer=ep.sendMessage(cmd);
      }
    }
    if (answer == null || !answer.getResult()) {
      if (cacheData != null) {
        cacheMgr.deleteCacheObject(cacheData);
      }
    }
    return answer;
  }
 catch (  Exception e) {
    s_logger.debug("String_Node_Str" + e.toString());
    if (cacheData != null) {
      cacheMgr.deleteCacheObject(cacheData);
    }
    throw new CloudRuntimeException(e.toString());
  }
}