coverity 1116718: neglected jarinputstream when no entry found

Signed-off-by: Daan Hoogland <daan@onecht.net>
This commit is contained in:
Daan Hoogland 2015-07-16 16:48:43 +02:00
parent 0c72f7743f
commit 8849d506cb

View File

@ -32,7 +32,6 @@ import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
@ -156,7 +155,7 @@ public class OnwireClassRegistry {
static Set<Class<?>> getFromJARFile(String jar, String packageName) throws IOException, ClassNotFoundException {
Set<Class<?>> classes = new HashSet<Class<?>>();
JarInputStream jarFile = new JarInputStream(new FileInputStream(jar));
try (JarInputStream jarFile = new JarInputStream(new FileInputStream(jar));) {
JarEntry jarEntry;
do {
jarEntry = jarFile.getNextJarEntry();
@ -175,10 +174,9 @@ public class OnwireClassRegistry {
}
}
} while (jarEntry != null);
IOUtils.closeQuietly(jarFile);
return classes;
}
}
static String stripFilenameExtension(String file) {
return file.substring(0, file.lastIndexOf('.'));