Skip to content

Commit d6ca04d

Browse files
committed
Merge pull request #45 from Leanplum/feature/fix-LP-4942
fix(ManifestHelper) fix close JarFile.
1 parent 1936603 commit d6ca04d

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

AndroidSDK/src/com/leanplum/internal/LeanplumManifestHelper.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,31 @@ private static byte[] getByteArrayOfManifest() {
100100
return null;
101101
}
102102
byte[] manifestXml = null;
103+
JarFile jarFile = null;
104+
DataInputStream dataInputStream = null;
103105
try {
104-
JarFile jarFile = new JarFile(context.getPackageResourcePath());
106+
jarFile = new JarFile(context.getPackageResourcePath());
105107
ZipEntry entry = jarFile.getEntry(ANDROID_MANIFEST);
106108
manifestXml = new byte[(int) entry.getSize()];
107-
DataInputStream dataInputStream = new DataInputStream(jarFile.getInputStream(entry));
109+
dataInputStream = new DataInputStream(jarFile.getInputStream(entry));
108110
dataInputStream.readFully(manifestXml);
109-
dataInputStream.close();
110111
} catch (Exception e) {
111112
Log.e("Cannot parse " + ANDROID_MANIFEST + " file: " + e.getMessage());
113+
} catch (Throwable t) {
114+
Log.e("Cannot parse " + ANDROID_MANIFEST + " file: " + t.getMessage());
115+
Util.handleException(t);
116+
} finally {
117+
try {
118+
if (jarFile != null) {
119+
jarFile.close();
120+
}
121+
122+
if (dataInputStream != null) {
123+
dataInputStream.close();
124+
}
125+
} catch (Throwable ignored) {
126+
127+
}
112128
}
113129
return manifestXml;
114130
}

0 commit comments

Comments
 (0)