From 12ddec9a7b3d00ebf1b1c2d88bc5c9985098b1a2 Mon Sep 17 00:00:00 2001 From: hneemann Date: Sun, 29 Oct 2017 09:35:37 +0100 Subject: [PATCH] fixed a file descriptor leak --- .../de/neemann/digital/draw/library/JarComponentManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/neemann/digital/draw/library/JarComponentManager.java b/src/main/java/de/neemann/digital/draw/library/JarComponentManager.java index 79f3ffb3c..ec678320b 100644 --- a/src/main/java/de/neemann/digital/draw/library/JarComponentManager.java +++ b/src/main/java/de/neemann/digital/draw/library/JarComponentManager.java @@ -51,7 +51,10 @@ public Iterator iterator() { * @throws InvalidNodeException InvalidNodeException */ public void loadJar(File file) throws IOException, InvalidNodeException { - Manifest manifest = new JarFile(file).getManifest(); + Manifest manifest; + try (JarFile jarFile = new JarFile(file)) { + manifest = jarFile.getManifest(); + } if (manifest == null) throw new IOException(Lang.get("err_noManifestFound")); Attributes attr = manifest.getMainAttributes();