Program: 106113
Project: 106113
Buggy source:
protected Answer copyObject(DataObject srcData,DataObject destData){
  String value=configDao.getValue(Config.PrimaryStorageDownloadWait.toString());
  int _primaryStorageDownloadWait=NumbersUtil.parseInt(value,Integer.parseInt(Config.PrimaryStorageDownloadWait.getDefaultValue()));
  Answer answer=null;
  DataObject cacheData=null;
  DataObject srcForCopy=srcData;
  try {
    if (needCacheStorage(srcData,destData)) {
      Scope destScope=pickCacheScopeForCopy(srcData,destData);
      srcForCopy=cacheData=cacheMgr.createCacheObject(srcData,destScope);
    }
    CopyCommand cmd=new CopyCommand(srcForCopy.getTO(),destData.getTO(),_primaryStorageDownloadWait,_mgmtServer.getExecuteInSequence());
    EndPoint ep=selector.select(srcForCopy,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 (cacheData != null) {
      if (srcData.getType() == DataObjectType.VOLUME && destData.getType() == DataObjectType.VOLUME) {
        cacheMgr.deleteCacheObject(srcForCopy);
      }
 else {
        if ((answer == null || !answer.getResult()) && srcForCopy.getRefCount() < 2) {
          cacheMgr.deleteCacheObject(srcForCopy);
        }
 else {
          cacheMgr.releaseCacheObject(srcForCopy);
        }
      }
    }
    return answer;
  }
 catch (  Exception e) {
    s_logger.debug("String_Node_Str",e);
    if (cacheData != null) {
      cacheMgr.deleteCacheObject(cacheData);
    }
    throw new CloudRuntimeException(e.toString());
  }
}

Fixed version (ground truth):
protected Answer copyObject(DataObject srcData,DataObject destData){
  String value=configDao.getValue(Config.PrimaryStorageDownloadWait.toString());
  int _primaryStorageDownloadWait=NumbersUtil.parseInt(value,Integer.parseInt(Config.PrimaryStorageDownloadWait.getDefaultValue()));
  Answer answer=null;
  DataObject cacheData=null;
  DataObject srcForCopy=srcData;
  try {
    if (needCacheStorage(srcData,destData)) {
      Scope destScope=pickCacheScopeForCopy(srcData,destData);
      srcForCopy=cacheData=cacheMgr.createCacheObject(srcData,destScope);
    }
    CopyCommand cmd=new CopyCommand(srcForCopy.getTO(),destData.getTO(),_primaryStorageDownloadWait,VirtualMachineManager.ExecuteInSequence.value());
    EndPoint ep=selector.select(srcForCopy,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 (cacheData != null) {
      if (srcData.getType() == DataObjectType.VOLUME && destData.getType() == DataObjectType.VOLUME) {
        cacheMgr.deleteCacheObject(srcForCopy);
      }
 else {
        if ((answer == null || !answer.getResult()) && srcForCopy.getRefCount() < 2) {
          cacheMgr.deleteCacheObject(srcForCopy);
        }
 else {
          cacheMgr.releaseCacheObject(srcForCopy);
        }
      }
    }
    return answer;
  }
 catch (  Exception e) {
    s_logger.debug("String_Node_Str",e);
    if (cacheData != null) {
      cacheMgr.deleteCacheObject(cacheData);
    }
    throw new CloudRuntimeException(e.toString());
  }
}