X Tutup
Skip to content

Commit d8d3946

Browse files
author
Marcus Linke
committed
use try-with-resource
1 parent ae6027c commit d8d3946

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/main/java/com/github/dockerjava/core/CompressArchiveUtil.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ public static File archiveTARFiles(File base, Iterable<File> files, String archi
1818
throws IOException {
1919
File tarFile = new File(FileUtils.getTempDirectoryPath(), archiveNameWithOutExtension + ".tar");
2020
tarFile.deleteOnExit();
21-
TarArchiveOutputStream tos = new TarArchiveOutputStream(new GZIPOutputStream(
22-
new BufferedOutputStream(new FileOutputStream(tarFile))));
23-
try {
21+
try(TarArchiveOutputStream tos = new TarArchiveOutputStream(new GZIPOutputStream(
22+
new BufferedOutputStream(new FileOutputStream(tarFile))))) {
2423
tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
2524
for (File file : files) {
2625
TarArchiveEntry tarEntry = new TarArchiveEntry(file);
@@ -39,8 +38,6 @@ public static File archiveTARFiles(File base, Iterable<File> files, String archi
3938
}
4039
tos.closeArchiveEntry();
4140
}
42-
} finally {
43-
tos.close();
4441
}
4542

4643
return tarFile;

0 commit comments

Comments
 (0)
X Tutup