Program: 119583
Project: 119583
Buggy source:
/** 
 * exports the jar to specific location.
 * @param root
 * @param list
 * @param manifest
 */
private void exportJar(File root,Collection<File> list,Manifest manifest) throws IOException {
  if (jarFile.exists()) {
    String tempFolderPath=jarFile.getParent() + File.separatorChar + TEMP;
    ZipFileUtils.unZip(jarFile,tempFolderPath);
    for (    File subf : list) {
      String desFileName=subf.getAbsolutePath().substring(root.getAbsolutePath().length() + 1);
      File srcFile=subf;
      while (!srcFile.getParentFile().getAbsolutePath().equals(root.getAbsolutePath())) {
        srcFile=srcFile.getParentFile();
      }
      createTempSubFolder(tempFolderPath,srcFile);
      FileChannel srcChannel=null;
      FileChannel dstChannel=null;
      try {
        srcChannel=new FileInputStream(subf.getAbsoluteFile()).getChannel();
        dstChannel=new FileOutputStream(tempFolderPath + File.separatorChar + desFileName).getChannel();
        dstChannel.transferFrom(srcChannel,0,srcChannel.size());
      }
  finally {
        if (null != srcChannel) {
          srcChannel.close();
        }
        if (null != dstChannel) {
          dstChannel.close();
        }
      }
    }
    ZipFileUtils.zip(tempFolderPath,jarFile.getPath(),false);
  }
 else {
    JarOutputStream jarOut=null;
    try {
      jarOut=new JarOutputStream(new FileOutputStream(jarFile),manifest);
      for (      File subf : list) {
        String filename=subf.getAbsolutePath().substring(root.getAbsolutePath().length() + 1);
        JarEntry entry=new JarEntry(filename.replace('\\','/'));
        jarOut.putNextEntry(entry);
        FileInputStream fin=new FileInputStream(subf);
        byte[] buf=new byte[4096];
        int read;
        while ((read=fin.read(buf)) != -1) {
          jarOut.write(buf,0,read);
        }
        fin.close();
        jarOut.closeEntry();
        jarOut.flush();
      }
    }
  finally {
      if (jarOut != null) {
        jarOut.close();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * exports the jar to specific location.
 * @param root
 * @param list
 * @param manifest
 */
private void exportJar(File root,Collection<File> list,Manifest manifest) throws IOException {
  if (jarFile.exists()) {
    StringBuffer tempFolderBuffer=new StringBuffer(jarFile.getParent());
    String tempFolderPath=tempFolderBuffer.append(File.separatorChar).toString();
    File tempFolder=getExportJarTempFolder();
    tempFolderPath=tempFolderPath + tempFolder.getName();
    ZipFileUtils.unZip(jarFile,tempFolderPath);
    for (    File subf : list) {
      String desFileName=subf.getAbsolutePath().substring(root.getAbsolutePath().length() + 1);
      File srcFile=subf;
      while (!srcFile.getParentFile().getAbsolutePath().equals(root.getAbsolutePath())) {
        srcFile=srcFile.getParentFile();
      }
      createTempSubFolder(tempFolderPath,srcFile);
      FileChannel srcChannel=null;
      FileChannel dstChannel=null;
      try {
        srcChannel=new FileInputStream(subf.getAbsoluteFile()).getChannel();
        dstChannel=new FileOutputStream(tempFolderPath + File.separatorChar + desFileName).getChannel();
        dstChannel.transferFrom(srcChannel,0,srcChannel.size());
      }
  finally {
        if (null != srcChannel) {
          srcChannel.close();
        }
        if (null != dstChannel) {
          dstChannel.close();
        }
      }
    }
    ZipFileUtils.zip(tempFolderPath,jarFile.getPath(),false);
  }
 else {
    JarOutputStream jarOut=null;
    try {
      jarOut=new JarOutputStream(new FileOutputStream(jarFile),manifest);
      for (      File subf : list) {
        String filename=subf.getAbsolutePath().substring(root.getAbsolutePath().length() + 1);
        JarEntry entry=new JarEntry(filename.replace('\\','/'));
        jarOut.putNextEntry(entry);
        FileInputStream fin=new FileInputStream(subf);
        byte[] buf=new byte[4096];
        int read;
        while ((read=fin.read(buf)) != -1) {
          jarOut.write(buf,0,read);
        }
        fin.close();
        jarOut.closeEntry();
        jarOut.flush();
      }
    }
  finally {
      if (jarOut != null) {
        jarOut.close();
      }
    }
  }
}