> +      checkArgument(baseDir.isDirectory(), "%s is not a directory", baseDir);
> +      File[] files = baseDir.listFiles();
> +      File tarFile = new File(archivePath);
> +
> +      String token = getLast(Splitter.on("/").split(archivePath.substring(0, 
> archivePath.lastIndexOf("/"))));
> +
> +      byte[] buf = new byte[1024];
> +      int len;
> +      TarArchiveOutputStream tos = new TarArchiveOutputStream(new 
> FileOutputStream(tarFile));
> +      tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
> +      for (File file : files) {
> +         TarArchiveEntry tarEntry = new TarArchiveEntry(file);
> +         tarEntry.setName("/" + 
> getLast(Splitter.on(token).split(file.toString())));
> +         tos.putArchiveEntry(tarEntry);
> +         if (!file.isDirectory()) {
> +            FileInputStream fin = new FileInputStream(file);

Too many calls to ```TarArchiveStream.close``` on the successful code path, not 
guaranteed to call on the exceptional path, and 
```TarArchiveStream.closeArchiveEntry``` not called when 
```!file.isDirectory```.  Otherwise the ```ByteSource``` change is a good 
improvement.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/57/files#r13241767

Reply via email to