Permalink
Browse files

Close zip entry streams.

  • Loading branch information...
1 parent b629641 commit cdf950c6283acfc8fe0413951be3f5cd3c22f433 @alesj alesj committed with n1hility Feb 23, 2012
Showing with 13 additions and 2 deletions.
  1. +13 −2 src/main/java/org/jboss/jandex/JarIndexer.java
@@ -84,12 +84,23 @@ public static Result createJarIndex(File jarFile, Indexer indexer, boolean modif
if (clone.getMethod() != ZipEntry.STORED)
clone.setCompressedSize(-1);
zo.putNextEntry(clone);
- copy(jar.getInputStream(entry), zo);
+ final InputStream stream = jar.getInputStream(entry);
+ try {
+ copy(stream, zo);
+ } finally {
+ safeClose(stream);
+ }
}
if (entry.getName().endsWith(".class")) {
try {
- ClassInfo info = indexer.index(jar.getInputStream(entry));
+ final InputStream stream = jar.getInputStream(entry);
+ ClassInfo info;
+ try {
+ info = indexer.index(stream);
+ } finally {
+ safeClose(stream);
+ }
if (verbose && info != null)
printIndexEntryInfo(info);
} catch (Exception e) {

0 comments on commit cdf950c

Please sign in to comment.