Program: 105335
Project: 105335
Buggy source:
public String postUpload(String uuid,String filename){
  UploadEntity uploadEntity=uploadEntityStateMap.get(uuid);
  int installTimeoutPerGig=180 * 60 * 1000;
  String resourcePath=uploadEntity.getInstallPathPrefix();
  String finalResourcePath=uploadEntity.getTmpltPath();
  UploadEntity.ResourceType resourceType=uploadEntity.getResourceType();
  String fileSavedTempLocation=uploadEntity.getInstallPathPrefix() + "String_Node_Str" + filename;
  String uploadedFileExtension=FilenameUtils.getExtension(filename);
  String userSelectedFormat=uploadEntity.getFormat().toString();
  if (uploadedFileExtension.equals("String_Node_Str") || uploadedFileExtension.equals("String_Node_Str") || uploadedFileExtension.equals("String_Node_Str")) {
    userSelectedFormat+="String_Node_Str" + uploadedFileExtension;
  }
  String formatError=ImageStoreUtil.checkTemplateFormat(fileSavedTempLocation,userSelectedFormat);
  if (StringUtils.isNotBlank(formatError)) {
    String errorString="String_Node_Str" + userSelectedFormat + "String_Node_Str"+ formatError;
    s_logger.error(errorString);
    return errorString;
  }
  int imgSizeGigs=getSizeInGB(_storage.getSize(fileSavedTempLocation));
  int maxSize=uploadEntity.getMaxSizeInGB();
  if (imgSizeGigs > maxSize) {
    String errorMessage="String_Node_Str" + imgSizeGigs + "String_Node_Str"+ maxSize+ "String_Node_Str";
    s_logger.error(errorMessage);
    return errorMessage;
  }
  imgSizeGigs++;
  long timeout=(long)imgSizeGigs * installTimeoutPerGig;
  Script scr=new Script(getScriptLocation(resourceType),timeout,s_logger);
  scr.add("String_Node_Str",Integer.toString(imgSizeGigs));
  scr.add("String_Node_Str",Long.toString(UploadEntity.s_maxTemplateSize));
  if (uploadEntity.getDescription() != null && uploadEntity.getDescription().length() > 1) {
    scr.add("String_Node_Str",uploadEntity.getDescription());
  }
  if (uploadEntity.isHvm()) {
    scr.add("String_Node_Str");
  }
  String checkSum=uploadEntity.getChksum();
  if (StringUtils.isNotBlank(checkSum)) {
    scr.add("String_Node_Str",checkSum);
  }
  String extension=uploadEntity.getFormat().getFileExtension();
  String templateName="String_Node_Str";
  if (extension.equals("String_Node_Str")) {
    templateName=uploadEntity.getUuid().trim().replace("String_Node_Str","String_Node_Str");
  }
 else {
    templateName=java.util.UUID.nameUUIDFromBytes((uploadEntity.getFilename() + System.currentTimeMillis()).getBytes()).toString();
  }
  String templateFilename=templateName + "String_Node_Str" + extension;
  uploadEntity.setTemplatePath(finalResourcePath + "String_Node_Str" + templateFilename);
  scr.add("String_Node_Str",templateFilename);
  scr.add("String_Node_Str",resourcePath);
  scr.add("String_Node_Str",fileSavedTempLocation);
  if (uploadEntity.getChksum() != null && uploadEntity.getChksum().length() > 1) {
    scr.add("String_Node_Str",uploadEntity.getChksum());
  }
  scr.add("String_Node_Str");
  String result;
  result=scr.execute();
  if (result != null) {
    return result;
  }
  File downloadedTemplate=new File(resourcePath + "String_Node_Str" + templateFilename);
  _storage.setWorldReadableAndWriteable(downloadedTemplate);
  String propertiesFile=resourcePath;
  if (resourceType == UploadEntity.ResourceType.TEMPLATE) {
    propertiesFile+="String_Node_Str";
  }
 else {
    propertiesFile+="String_Node_Str";
  }
  File templateProperties=new File(propertiesFile);
  _storage.setWorldReadableAndWriteable(templateProperties);
  TemplateLocation loc=new TemplateLocation(_storage,resourcePath);
  try {
    loc.create(uploadEntity.getEntityId(),true,uploadEntity.getFilename());
  }
 catch (  IOException e) {
    s_logger.warn("String_Node_Str" + resourcePath,e);
    loc.purge();
    return "String_Node_Str" + e.getMessage();
  }
  Map<String,Processor> processors=_dlMgr.getProcessors();
  for (  Processor processor : processors.values()) {
    FormatInfo info=null;
    try {
      info=processor.process(resourcePath,null,templateName);
    }
 catch (    InternalErrorException e) {
      s_logger.error("String_Node_Str",e);
      return e.toString();
    }
    if (info != null) {
      loc.addFormat(info);
      uploadEntity.setVirtualSize(info.virtualSize);
      uploadEntity.setPhysicalSize(info.size);
      break;
    }
  }
  if (!loc.save()) {
    s_logger.warn("String_Node_Str");
    loc.purge();
  }
  uploadEntity.setStatus(UploadEntity.Status.COMPLETED);
  uploadEntityStateMap.put(uploadEntity.getUuid(),uploadEntity);
  return null;
}

Fixed version (ground truth):
public String postUpload(String uuid,String filename){
  UploadEntity uploadEntity=uploadEntityStateMap.get(uuid);
  int installTimeoutPerGig=180 * 60 * 1000;
  String resourcePath=uploadEntity.getInstallPathPrefix();
  String finalResourcePath=uploadEntity.getTmpltPath();
  UploadEntity.ResourceType resourceType=uploadEntity.getResourceType();
  String fileSavedTempLocation=uploadEntity.getInstallPathPrefix() + "String_Node_Str" + filename;
  String uploadedFileExtension=FilenameUtils.getExtension(filename);
  String userSelectedFormat=uploadEntity.getFormat().toString();
  if (uploadedFileExtension.equals("String_Node_Str") || uploadedFileExtension.equals("String_Node_Str") || uploadedFileExtension.equals("String_Node_Str")) {
    userSelectedFormat+="String_Node_Str" + uploadedFileExtension;
  }
  String formatError=ImageStoreUtil.checkTemplateFormat(fileSavedTempLocation,userSelectedFormat);
  if (StringUtils.isNotBlank(formatError)) {
    String errorString="String_Node_Str" + userSelectedFormat + "String_Node_Str"+ formatError;
    s_logger.error(errorString);
    return errorString;
  }
  int imgSizeGigs=getSizeInGB(_storage.getSize(fileSavedTempLocation));
  int maxSize=uploadEntity.getMaxSizeInGB();
  if (imgSizeGigs > maxSize) {
    String errorMessage="String_Node_Str" + imgSizeGigs + "String_Node_Str"+ maxSize+ "String_Node_Str";
    s_logger.error(errorMessage);
    return errorMessage;
  }
  imgSizeGigs++;
  long timeout=(long)imgSizeGigs * installTimeoutPerGig;
  Script scr=new Script(getScriptLocation(resourceType),timeout,s_logger);
  scr.add("String_Node_Str",Integer.toString(imgSizeGigs));
  scr.add("String_Node_Str",Long.toString(UploadEntity.s_maxTemplateSize));
  if (uploadEntity.getDescription() != null && uploadEntity.getDescription().length() > 1) {
    scr.add("String_Node_Str",uploadEntity.getDescription());
  }
  if (uploadEntity.isHvm()) {
    scr.add("String_Node_Str");
  }
  String checkSum=uploadEntity.getChksum();
  if (StringUtils.isNotBlank(checkSum)) {
    scr.add("String_Node_Str",checkSum);
  }
  String extension=uploadEntity.getFormat().getFileExtension();
  String templateName="String_Node_Str";
  if (extension.equals("String_Node_Str")) {
    templateName=uploadEntity.getUuid().trim().replace("String_Node_Str","String_Node_Str");
  }
 else {
    try {
      templateName=UUID.nameUUIDFromBytes((uploadEntity.getFilename() + System.currentTimeMillis()).getBytes("String_Node_Str")).toString();
    }
 catch (    UnsupportedEncodingException e) {
      templateName=uploadEntity.getUuid().trim().replace("String_Node_Str","String_Node_Str");
    }
  }
  String templateFilename=templateName + "String_Node_Str" + extension;
  uploadEntity.setTemplatePath(finalResourcePath + "String_Node_Str" + templateFilename);
  scr.add("String_Node_Str",templateFilename);
  scr.add("String_Node_Str",resourcePath);
  scr.add("String_Node_Str",fileSavedTempLocation);
  if (uploadEntity.getChksum() != null && uploadEntity.getChksum().length() > 1) {
    scr.add("String_Node_Str",uploadEntity.getChksum());
  }
  scr.add("String_Node_Str");
  String result;
  result=scr.execute();
  if (result != null) {
    return result;
  }
  File downloadedTemplate=new File(resourcePath + "String_Node_Str" + templateFilename);
  _storage.setWorldReadableAndWriteable(downloadedTemplate);
  String propertiesFile=resourcePath;
  if (resourceType == UploadEntity.ResourceType.TEMPLATE) {
    propertiesFile+="String_Node_Str";
  }
 else {
    propertiesFile+="String_Node_Str";
  }
  File templateProperties=new File(propertiesFile);
  _storage.setWorldReadableAndWriteable(templateProperties);
  TemplateLocation loc=new TemplateLocation(_storage,resourcePath);
  try {
    loc.create(uploadEntity.getEntityId(),true,uploadEntity.getFilename());
  }
 catch (  IOException e) {
    s_logger.warn("String_Node_Str" + resourcePath,e);
    loc.purge();
    return "String_Node_Str" + e.getMessage();
  }
  Map<String,Processor> processors=_dlMgr.getProcessors();
  for (  Processor processor : processors.values()) {
    FormatInfo info=null;
    try {
      info=processor.process(resourcePath,null,templateName);
    }
 catch (    InternalErrorException e) {
      s_logger.error("String_Node_Str",e);
      return e.toString();
    }
    if (info != null) {
      loc.addFormat(info);
      uploadEntity.setVirtualSize(info.virtualSize);
      uploadEntity.setPhysicalSize(info.size);
      break;
    }
  }
  if (!loc.save()) {
    s_logger.warn("String_Node_Str");
    loc.purge();
  }
  uploadEntity.setStatus(UploadEntity.Status.COMPLETED);
  uploadEntityStateMap.put(uploadEntity.getUuid(),uploadEntity);
  return null;
}