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 78a7cf00ef
commit 332577942f

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) {