summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-10-17 11:54:52 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-10-17 11:54:53 +0000
commit1f7fcec1e92df937952e9996a7fc42947501e1d9 (patch)
tree68d978e7828522013c59f08de1fd74a94306333a
parentc2f096c885d3dcd2fc5e4d613cda12fb39d5b9c5 (diff)
parentb369ebdb7fcad44420b43593e908183f95bfa8ea (diff)
downloadlibcore-1f7fcec1e92df937952e9996a7fc42947501e1d9.zip
libcore-1f7fcec1e92df937952e9996a7fc42947501e1d9.tar.gz
libcore-1f7fcec1e92df937952e9996a7fc42947501e1d9.tar.bz2
Merge "Fix resource leak in StrictJarFile."
-rw-r--r--luni/src/main/java/java/util/jar/StrictJarFile.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/luni/src/main/java/java/util/jar/StrictJarFile.java b/luni/src/main/java/java/util/jar/StrictJarFile.java
index fa175d8..df8e751 100644
--- a/luni/src/main/java/java/util/jar/StrictJarFile.java
+++ b/luni/src/main/java/java/util/jar/StrictJarFile.java
@@ -53,7 +53,7 @@ public final class StrictJarFile {
private final CloseGuard guard = CloseGuard.get();
private boolean closed;
- public StrictJarFile(String fileName) throws IOException {
+ public StrictJarFile(String fileName) throws IOException, SecurityException {
this.nativeHandle = nativeOpenJarFile(fileName);
this.raf = new RandomAccessFile(fileName, "r");
@@ -66,9 +66,10 @@ public final class StrictJarFile {
this.verifier = new JarVerifier(fileName, manifest, metaEntries);
isSigned = verifier.readCertificates() && verifier.isSignedJar();
- } catch (IOException ioe) {
+ } catch (IOException | SecurityException e) {
nativeClose(this.nativeHandle);
- throw ioe;
+ IoUtils.closeQuietly(this.raf);
+ throw e;
}
guard.open("close");