diff --git a/src/main/java/org/jboss/jandex/JarIndexer.java b/src/main/java/org/jboss/jandex/JarIndexer.java index 830535f0..31d9f79c 100644 --- a/src/main/java/org/jboss/jandex/JarIndexer.java +++ b/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) {