Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarFile.java5
2 files changed, 5 insertions, 7 deletions
diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java
index 17dfd95f9..6f17bc0dd 100644
--- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java
+++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2017 IBM Corporation and others.
+ * Copyright (c) 2007, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,9 +20,8 @@ import org.eclipse.osgi.util.NLS;
public class FileUtils {
private static File[] untarFile(File source, File outputDir) throws IOException, TarException {
- TarFile tarFile = new TarFile(source);
List<File> untarredFiles = new ArrayList<>();
- try {
+ try (TarFile tarFile = new TarFile(source)) {
for (Enumeration<TarEntry> e = tarFile.entries(); e.hasMoreElements();) {
TarEntry entry = e.nextElement();
try (InputStream input = tarFile.getInputStream(entry)) {
@@ -46,8 +45,6 @@ public class FileUtils {
}
}
}
- } finally {
- tarFile.close();
}
return untarredFiles.toArray(new File[untarredFiles.size()]);
}
diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarFile.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarFile.java
index ef93fcb82..31bdbec46 100644
--- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarFile.java
+++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarFile.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2017 IBM Corporation and others.
+ * Copyright (c) 2008, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,7 +17,7 @@ import java.util.zip.GZIPInputStream;
/**
* Copied from org.eclipse.ui.internal.wizards.datatransfer.TarFile.
*/
-public class TarFile {
+public class TarFile implements Closeable {
private File file;
private TarInputStream entryEnumerationStream;
private TarEntry curEntry;
@@ -59,6 +59,7 @@ public class TarFile {
*
* @throws IOException if the file cannot be successfully closed
*/
+ @Override
public void close() throws IOException {
entryEnumerationStream.close();
if (internalEntryStream != null)

Back to the top