Program: 44643
Project: 44643
Buggy source:
public void exportContentObjectList(ContentObjectCriteria contentObjectCriteria,String zipFilename){
  CmsOutcome<ContentObject> cmsOutcome=astroboaClient.getContentService().searchContentObjects(contentObjectCriteria,ResourceRepresentationType.CONTENT_OBJECT_LIST);
  if (cmsOutcome == null || cmsOutcome.getCount() == 0) {
    JSFUtilities.addMessage(null,"String_Node_Str",null,FacesMessage.SEVERITY_WARN);
    return;
  }
  FacesContext facesContext=FacesContext.getCurrentInstance();
  if (!facesContext.getResponseComplete()) {
    HttpServletResponse response=(HttpServletResponse)facesContext.getExternalContext().getResponse();
    response.setContentType("String_Node_Str");
    response.setCharacterEncoding("String_Node_Str");
    if (StringUtils.isBlank(zipFilename)) {
      zipFilename="String_Node_Str";
    }
    response.setHeader("String_Node_Str","String_Node_Str" + FilenameUtils.convertFilenameGreekCharactersToEnglishAndReplaceInvalidCharacters(zipFilename.trim()) + "String_Node_Str");
    File tempZip=null;
    FileOutputStream fos=null;
    ZipOutputStream zipOutputStream=null;
    FileInputStream zipFileInputStream=null;
    try {
      tempZip=File.createTempFile(zipFilename,"String_Node_Str");
      fos=new FileOutputStream(tempZip);
      zipOutputStream=new ZipOutputStream(fos);
      List<ContentObject> results=cmsOutcome.getResults();
      List<String> filenameList=new ArrayList<String>();
      int numbreOfContentObjects=500;
      long now=System.currentTimeMillis();
      for (      ContentObject contentObject : results) {
        if (numbreOfContentObjects == 0) {
          break;
        }
        Calendar created=((CalendarProperty)contentObject.getCmsProperty("String_Node_Str")).getSimpleTypeValue();
        String folderPath=DateUtils.format(created,"String_Node_Str");
        long nowXml=System.currentTimeMillis();
        String xml=contentObject.xml(true);
        String finalName=buildFilename(folderPath,created,contentObject,filenameList);
        filenameList.add(finalName);
        long nowZip=System.currentTimeMillis();
        zipOutputStream.putNextEntry(new ZipEntry(finalName));
        IOUtils.write(xml,zipOutputStream);
        zipOutputStream.closeEntry();
        numbreOfContentObjects--;
      }
      zipOutputStream.close();
      fos.close();
      long nowFileZip=System.currentTimeMillis();
      zipFileInputStream=new FileInputStream(tempZip);
      IOUtils.copy(zipFileInputStream,response.getOutputStream());
      zipFileInputStream.close();
      facesContext.responseComplete();
    }
 catch (    IOException e) {
      logger.error("String_Node_Str",e);
      JSFUtilities.addMessage(null,"String_Node_Str",null,FacesMessage.SEVERITY_WARN);
    }
 finally {
      if (fos != null) {
        IOUtils.closeQuietly(fos);
      }
      if (zipOutputStream != null) {
        IOUtils.closeQuietly(zipOutputStream);
      }
      if (zipFileInputStream != null) {
        IOUtils.closeQuietly(zipFileInputStream);
      }
      if (tempZip != null) {
        FileUtils.deleteQuietly(tempZip);
      }
    }
  }
 else {
    JSFUtilities.addMessage(null,"String_Node_Str",null,FacesMessage.SEVERITY_WARN);
  }
}

Fixed version (ground truth):
public void exportContentObjectList(ContentObjectCriteria contentObjectCriteria,String zipFilename){
  CmsOutcome<ContentObject> cmsOutcome=astroboaClient.getContentService().searchContentObjects(contentObjectCriteria,ResourceRepresentationType.CONTENT_OBJECT_LIST);
  if (cmsOutcome == null || cmsOutcome.getCount() == 0) {
    JSFUtilities.addMessage(null,"String_Node_Str",null,FacesMessage.SEVERITY_WARN);
    return;
  }
  FacesContext facesContext=FacesContext.getCurrentInstance();
  if (!facesContext.getResponseComplete()) {
    HttpServletResponse response=(HttpServletResponse)facesContext.getExternalContext().getResponse();
    response.setContentType("String_Node_Str");
    response.setCharacterEncoding("String_Node_Str");
    zipFilename=generateValidZipFilename(zipFilename);
    response.setHeader("String_Node_Str","String_Node_Str" + zipFilename + "String_Node_Str");
    File tempZip=null;
    FileOutputStream fos=null;
    ZipOutputStream zipOutputStream=null;
    FileInputStream zipFileInputStream=null;
    try {
      tempZip=File.createTempFile(zipFilename,"String_Node_Str");
      fos=new FileOutputStream(tempZip);
      zipOutputStream=new ZipOutputStream(fos);
      List<ContentObject> results=cmsOutcome.getResults();
      List<String> filenameList=new ArrayList<String>();
      int numbreOfContentObjects=500;
      long now=System.currentTimeMillis();
      for (      ContentObject contentObject : results) {
        if (numbreOfContentObjects == 0) {
          break;
        }
        Calendar created=((CalendarProperty)contentObject.getCmsProperty("String_Node_Str")).getSimpleTypeValue();
        String folderPath=DateUtils.format(created,"String_Node_Str");
        long nowXml=System.currentTimeMillis();
        String xml=contentObject.xml(true);
        String finalName=buildFilename(folderPath,created,contentObject,filenameList);
        filenameList.add(finalName);
        long nowZip=System.currentTimeMillis();
        zipOutputStream.putNextEntry(new ZipEntry(finalName));
        IOUtils.write(xml,zipOutputStream);
        zipOutputStream.closeEntry();
        numbreOfContentObjects--;
      }
      zipOutputStream.close();
      fos.close();
      long nowFileZip=System.currentTimeMillis();
      zipFileInputStream=new FileInputStream(tempZip);
      IOUtils.copy(zipFileInputStream,response.getOutputStream());
      zipFileInputStream.close();
      facesContext.responseComplete();
    }
 catch (    IOException e) {
      logger.error("String_Node_Str",e);
      JSFUtilities.addMessage(null,"String_Node_Str",null,FacesMessage.SEVERITY_WARN);
    }
 finally {
      if (fos != null) {
        IOUtils.closeQuietly(fos);
      }
      if (zipOutputStream != null) {
        IOUtils.closeQuietly(zipOutputStream);
      }
      if (zipFileInputStream != null) {
        IOUtils.closeQuietly(zipFileInputStream);
      }
      if (tempZip != null) {
        FileUtils.deleteQuietly(tempZip);
      }
    }
  }
 else {
    JSFUtilities.addMessage(null,"String_Node_Str",null,FacesMessage.SEVERITY_WARN);
  }
}