From ff40bce89176c9c9d3066dec744d21c41bb96ac7 Mon Sep 17 00:00:00 2001 From: Mark Rogers Date: Tue, 15 Mar 2016 10:55:54 +0000 Subject: [PATCH] Merged WOLF-6 (WOLF.0.0) to 5.1.1 (5.1.1) 111926 adavis: Merged 5.0.N (5.0.3) to WOLF-6 (WOLF.0.0) 111638: UTF-242: refactored archive unpacking code to use try-with-resources for brevity. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/services/full-installer/branches/5.1.1@123920 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../pkg/test/TgzFormatIntegrationTest.java | 34 ++++--------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/enterprise-update/src/test/java/org/alfresco/update/pkg/test/TgzFormatIntegrationTest.java b/enterprise-update/src/test/java/org/alfresco/update/pkg/test/TgzFormatIntegrationTest.java index 82c0bda663..6b55c550fb 100644 --- a/enterprise-update/src/test/java/org/alfresco/update/pkg/test/TgzFormatIntegrationTest.java +++ b/enterprise-update/src/test/java/org/alfresco/update/pkg/test/TgzFormatIntegrationTest.java @@ -96,17 +96,14 @@ public class TgzFormatIntegrationTest extends AbstractIntegrationTest private void handleArchiveEntries(InputStream raw, ArchiveEntryHandler handler) throws ArchiveException, IOException, CompressorException { - CompressorInputStream gzIs = null; - BufferedInputStream bis = null; - TarArchiveInputStream aris = null; - BufferedInputStream bgzIs = null; try + ( + BufferedInputStream bis = new BufferedInputStream(raw); + CompressorInputStream gzIs = new CompressorStreamFactory().createCompressorInputStream(bis); + BufferedInputStream bgzIs = new BufferedInputStream(gzIs); + TarArchiveInputStream aris = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream(bgzIs); + ) { - bis = new BufferedInputStream(raw); - gzIs = new CompressorStreamFactory().createCompressorInputStream(bis); - bgzIs = new BufferedInputStream(gzIs); - aris = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream(bgzIs); - TarArchiveEntry entry = null; boolean carryOn = true; while (carryOn && (entry = aris.getNextTarEntry()) != null) @@ -114,24 +111,5 @@ public class TgzFormatIntegrationTest extends AbstractIntegrationTest carryOn = handler.handle(entry); } } - finally - { - if (aris != null) - { - aris.close(); - } - if (bgzIs != null) - { - bgzIs.close(); - } - if (gzIs != null) - { - gzIs.close(); - } - if (bis != null) - { - bis.close(); - } - } } }