From 45e79fb2c635360f0afe589a47dd571f37158540 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Wed, 4 Nov 2015 10:58:39 +0100 Subject: [PATCH] fix: cleanup open files in "certificateProfile" --- src/org/cacert/gigi/dbObjects/CertificateProfile.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/org/cacert/gigi/dbObjects/CertificateProfile.java b/src/org/cacert/gigi/dbObjects/CertificateProfile.java index 0e6f29ba..87f55f74 100644 --- a/src/org/cacert/gigi/dbObjects/CertificateProfile.java +++ b/src/org/cacert/gigi/dbObjects/CertificateProfile.java @@ -126,7 +126,9 @@ public class CertificateProfile implements IdCachable { private CertificateProfile(File f) throws IOException { Properties p = new Properties(); - p.load(new FileInputStream(f)); + try (FileInputStream inStream = new FileInputStream(f)) { + p.load(inStream); + } String[] parts = f.getName().split("\\.")[0].split("-", 2); id = Integer.parseInt(parts[0]); keyName = parts[1]; @@ -181,8 +183,8 @@ public class CertificateProfile implements IdCachable { for (File f : new File("config/profiles").listFiles()) { Properties p = new Properties(); - try { - p.load(new FileInputStream(f)); + try (FileInputStream inStream = new FileInputStream(f)) { + p.load(inStream); } catch (IOException e) { throw new Error("Unable to load profile from " + f.getName(), e); } -- 2.39.2