Program: 89335
Project: 89335
Buggy source:
private Long extract(Account caller,Long templateId,String url,Long zoneId,String mode,Long eventId,boolean isISO,AsyncJobVO job,AsyncJobManager mgr){
  String desc="String_Node_Str";
  if (isISO) {
    desc="String_Node_Str";
  }
  eventId=eventId == null ? 0 : eventId;
  VMTemplateVO template=_tmpltDao.findById(templateId);
  if (template == null || template.getRemoved() != null) {
    throw new InvalidParameterValueException("String_Node_Str" + desc + "String_Node_Str"+ templateId);
  }
  if (template.getTemplateType() == Storage.TemplateType.SYSTEM) {
    throw new InvalidParameterValueException("String_Node_Str" + desc + "String_Node_Str"+ template.getName()+ "String_Node_Str");
  }
  if (template.getTemplateType() == Storage.TemplateType.PERHOST) {
    throw new InvalidParameterValueException("String_Node_Str" + desc + "String_Node_Str"+ template.getName()+ "String_Node_Str");
  }
  if (isISO) {
    if (template.getFormat() != ImageFormat.ISO) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
  }
 else {
    if (template.getFormat() == ImageFormat.ISO) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
  }
  if (_dcDao.findById(zoneId) == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!template.isExtractable()) {
    throw new InvalidParameterValueException("String_Node_Str" + templateId + "String_Node_Str");
  }
  _accountMgr.checkAccess(caller,AccessType.ModifyEntry,template);
  List<HostVO> sservers=_storageMgr.getSecondaryStorageHosts(zoneId);
  VMTemplateHostVO tmpltHostRef=null;
  if (sservers != null) {
    for (    HostVO secondaryStorageHost : sservers) {
      tmpltHostRef=_tmpltHostDao.findByHostTemplate(secondaryStorageHost.getId(),templateId);
      if (tmpltHostRef != null) {
        if (tmpltHostRef.getDownloadState() != com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
          tmpltHostRef=null;
        }
 else {
          break;
        }
      }
    }
  }
  if (tmpltHostRef == null) {
    throw new InvalidParameterValueException("String_Node_Str" + desc + "String_Node_Str");
  }
  Upload.Mode extractMode;
  if (mode == null || (!mode.equals(Upload.Mode.FTP_UPLOAD.toString()) && !mode.equals(Upload.Mode.HTTP_DOWNLOAD.toString()))) {
    throw new InvalidParameterValueException("String_Node_Str" + Upload.Mode.values());
  }
 else {
    extractMode=mode.equals(Upload.Mode.FTP_UPLOAD.toString()) ? Upload.Mode.FTP_UPLOAD : Upload.Mode.HTTP_DOWNLOAD;
  }
  if (extractMode == Upload.Mode.FTP_UPLOAD) {
    URI uri=null;
    try {
      uri=new URI(url);
      if ((uri.getScheme() == null) || (!uri.getScheme().equalsIgnoreCase("String_Node_Str"))) {
        throw new InvalidParameterValueException("String_Node_Str" + url);
      }
    }
 catch (    Exception ex) {
      throw new InvalidParameterValueException("String_Node_Str" + url);
    }
    String host=uri.getHost();
    try {
      InetAddress hostAddr=InetAddress.getByName(host);
      if (hostAddr.isAnyLocalAddress() || hostAddr.isLinkLocalAddress() || hostAddr.isLoopbackAddress()|| hostAddr.isMulticastAddress()) {
        throw new InvalidParameterValueException("String_Node_Str");
      }
      if (hostAddr instanceof Inet6Address) {
        throw new InvalidParameterValueException("String_Node_Str" + hostAddr.getHostAddress() + "String_Node_Str");
      }
    }
 catch (    UnknownHostException uhe) {
      throw new InvalidParameterValueException("String_Node_Str" + host);
    }
    if (_uploadMonitor.isTypeUploadInProgress(templateId,isISO ? Type.ISO : Type.TEMPLATE)) {
      throw new IllegalArgumentException(template.getName() + "String_Node_Str");
    }
    return _uploadMonitor.extractTemplate(template,url,tmpltHostRef,zoneId,eventId,job.getId(),mgr);
  }
  UploadVO vo=_uploadMonitor.createEntityDownloadURL(template,tmpltHostRef,zoneId,eventId);
  if (vo != null) {
    return vo.getId();
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
private Long extract(Account caller,Long templateId,String url,Long zoneId,String mode,Long eventId,boolean isISO,AsyncJobVO job,AsyncJobManager mgr){
  String desc=Upload.Type.TEMPLATE.toString();
  if (isISO) {
    desc=Upload.Type.ISO.toString();
  }
  eventId=eventId == null ? 0 : eventId;
  VMTemplateVO template=_tmpltDao.findById(templateId);
  if (template == null || template.getRemoved() != null) {
    throw new InvalidParameterValueException("String_Node_Str" + desc + "String_Node_Str"+ templateId);
  }
  if (template.getTemplateType() == Storage.TemplateType.SYSTEM) {
    throw new InvalidParameterValueException("String_Node_Str" + desc + "String_Node_Str"+ template.getName()+ "String_Node_Str");
  }
 else   if (template.getTemplateType() == Storage.TemplateType.PERHOST) {
    throw new InvalidParameterValueException("String_Node_Str" + desc + "String_Node_Str"+ template.getName()+ "String_Node_Str");
  }
  if (isISO) {
    if (template.getFormat() != ImageFormat.ISO) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
  }
 else {
    if (template.getFormat() == ImageFormat.ISO) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
  }
  if (_dcDao.findById(zoneId) == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!template.isExtractable()) {
    throw new InvalidParameterValueException("String_Node_Str" + templateId + "String_Node_Str");
  }
  _accountMgr.checkAccess(caller,AccessType.ModifyEntry,template);
  List<HostVO> sservers=_storageMgr.getSecondaryStorageHosts(zoneId);
  VMTemplateHostVO tmpltHostRef=null;
  if (sservers != null) {
    for (    HostVO secondaryStorageHost : sservers) {
      tmpltHostRef=_tmpltHostDao.findByHostTemplate(secondaryStorageHost.getId(),templateId);
      if (tmpltHostRef != null) {
        if (tmpltHostRef.getDownloadState() != com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
          tmpltHostRef=null;
        }
 else {
          break;
        }
      }
    }
  }
  if (tmpltHostRef == null) {
    throw new InvalidParameterValueException("String_Node_Str" + desc + "String_Node_Str");
  }
  Upload.Mode extractMode;
  if (mode == null || (!mode.equalsIgnoreCase(Upload.Mode.FTP_UPLOAD.toString()) && !mode.equalsIgnoreCase(Upload.Mode.HTTP_DOWNLOAD.toString()))) {
    throw new InvalidParameterValueException("String_Node_Str" + Upload.Mode.FTP_UPLOAD + "String_Node_Str"+ Upload.Mode.HTTP_DOWNLOAD);
  }
 else {
    extractMode=mode.equalsIgnoreCase(Upload.Mode.FTP_UPLOAD.toString()) ? Upload.Mode.FTP_UPLOAD : Upload.Mode.HTTP_DOWNLOAD;
  }
  if (extractMode == Upload.Mode.FTP_UPLOAD) {
    URI uri=null;
    try {
      uri=new URI(url);
      if ((uri.getScheme() == null) || (!uri.getScheme().equalsIgnoreCase("String_Node_Str"))) {
        throw new InvalidParameterValueException("String_Node_Str" + url);
      }
    }
 catch (    Exception ex) {
      throw new InvalidParameterValueException("String_Node_Str" + url);
    }
    String host=uri.getHost();
    try {
      InetAddress hostAddr=InetAddress.getByName(host);
      if (hostAddr.isAnyLocalAddress() || hostAddr.isLinkLocalAddress() || hostAddr.isLoopbackAddress()|| hostAddr.isMulticastAddress()) {
        throw new InvalidParameterValueException("String_Node_Str");
      }
      if (hostAddr instanceof Inet6Address) {
        throw new InvalidParameterValueException("String_Node_Str" + hostAddr.getHostAddress() + "String_Node_Str");
      }
    }
 catch (    UnknownHostException uhe) {
      throw new InvalidParameterValueException("String_Node_Str" + host);
    }
    if (_uploadMonitor.isTypeUploadInProgress(templateId,isISO ? Type.ISO : Type.TEMPLATE)) {
      throw new IllegalArgumentException(template.getName() + "String_Node_Str");
    }
    return _uploadMonitor.extractTemplate(template,url,tmpltHostRef,zoneId,eventId,job.getId(),mgr);
  }
  UploadVO vo=_uploadMonitor.createEntityDownloadURL(template,tmpltHostRef,zoneId,eventId);
  if (vo != null) {
    return vo.getId();
  }
 else {
    return null;
  }
}