bug 709330 - AboutHomeContent.getRecommendedAddonsStream() resource leak because ZipFile was not closed r=mfinkle

This commit is contained in:
Brad Lassey 2011-12-16 20:22:34 -05:00
parent 35fbd86079
commit 5e5c6bb313

View File

@ -236,13 +236,19 @@ public class AboutHomeContent extends ScrollView {
if (is != null)
return is;
File applicationPackage = new File(activity.getApplication().getPackageResourcePath());
ZipFile zip = new ZipFile(applicationPackage);
if (zip == null)
return null;
ZipEntry fileEntry = zip.getEntry("recommended-addons.json");
if (fileEntry == null)
return null;
return zip.getInputStream(fileEntry);
ZipFile zip = null;
try {
zip = new ZipFile(applicationPackage);
if (zip == null)
return null;
ZipEntry fileEntry = zip.getEntry("recommended-addons.json");
if (fileEntry == null)
return null;
return zip.getInputStream(fileEntry);
} finally {
if (zip != null)
zip.close();
}
}
void readRecommendedAddons(final Activity activity) {