Program: 44644
Project: 44644
Buggy source:
public void exportContentObjectSelection(ContentObjectSelectionBean contentObjectSelection,String zipFilename){
  if (contentObjectSelection == null || CollectionUtils.isEmpty(contentObjectSelection.getSelectedContentObjects())) {
    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<ContentObjectUIWrapper> results=contentObjectSelection.getSelectedContentObjects();
      List<String> filenameList=new ArrayList<String>();
      int numbreOfContentObjects=500;
      long now=System.currentTimeMillis();
      for (      ContentObjectUIWrapper contentObjectUiWraper : results) {
        if (numbreOfContentObjects == 0) {
          break;
        }
        ContentObject contentObject=contentObjectUiWraper.getContentObject();
        Calendar created=((CalendarProperty)contentObject.getCmsProperty("String_Node_Str")).getSimpleTypeValue();
        String folderPath=DateUtils.format(created,"String_Node_Str");
        long nowXml=System.currentTimeMillis();
        String xml=contentObject.toXml();
        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 exportContentObjectSelection(ContentObjectSelectionBean contentObjectSelection,String zipFilename){
  if (contentObjectSelection == null || CollectionUtils.isEmpty(contentObjectSelection.getSelectedContentObjects())) {
    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<ContentObjectUIWrapper> results=contentObjectSelection.getSelectedContentObjects();
      List<String> filenameList=new ArrayList<String>();
      int numbreOfContentObjects=500;
      long now=System.currentTimeMillis();
      for (      ContentObjectUIWrapper contentObjectUiWraper : results) {
        if (numbreOfContentObjects == 0) {
          break;
        }
        ContentObject contentObject=contentObjectUiWraper.getContentObject();
        Calendar created=((CalendarProperty)contentObject.getCmsProperty("String_Node_Str")).getSimpleTypeValue();
        String folderPath=DateUtils.format(created,"String_Node_Str");
        long nowXml=System.currentTimeMillis();
        String xml=contentObject.toXml();
        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);
  }
}