fix: resource leaks in OCSPIssuerManager
authorBenny Baumann <BenBE1987@gmx.net>
Tue, 20 Feb 2018 20:37:45 +0000 (21:37 +0100)
committerBenny Baumann <BenBE1987@gmx.net>
Tue, 20 Feb 2018 20:48:14 +0000 (21:48 +0100)
Change-Id: I15aa074af09c07b72ddb953fa8d1f63b6ae3eb88

src/club/wpia/gigi/ocsp/OCSPIssuerManager.java

index 400737f..3634337 100644 (file)
@@ -225,7 +225,9 @@ public class OCSPIssuerManager implements Runnable {
                         if (ks.length() == 0) {
                             keys.load(null);
                         } else {
-                            keys.load(new FileInputStream(ks), "pass".toCharArray());
+                            try (FileInputStream ks_file = new FileInputStream(ks)) {
+                                keys.load(ks_file, "pass".toCharArray());
+                            }
                         }
                     } else {
                         // assuming ocsp is disabled
@@ -239,8 +241,8 @@ public class OCSPIssuerManager implements Runnable {
                 Map<String, OCSPIssuer> toServe = new HashMap<>();
 
                 scanAndUpdateCAs(f, keys, toServe);
-                try {
-                    keys.store(new FileOutputStream(ks), "pass".toCharArray());
+                try (FileOutputStream ks_file = new FileOutputStream(ks)) {
+                    keys.store(ks_file, "pass".toCharArray());
                 } catch (GeneralSecurityException e) {
                     throw new Error(e);
                 } catch (IOException e) {