[Git][java-team/ca-certificates-java][master] keystore: Close file descriptor in case of exception
Bastien Roucariès (@rouca)
gitlab at salsa.debian.org
Wed Mar 25 09:08:13 GMT 2026
Bastien Roucariès pushed to branch master at Debian Java Maintainers / ca-certificates-java
Commits:
429b952c by Arnaud Rebillout at 2026-03-23T14:47:28+07:00
keystore: Close file descriptor in case of exception
- - - - -
1 changed file:
- src/main/java/org/debian/security/KeyStoreHandler.java
Changes:
=====================================
src/main/java/org/debian/security/KeyStoreHandler.java
=====================================
@@ -90,7 +90,7 @@ class KeyStoreHandler {
/**
* Add or replace existing cert in keystore with given alias.
*/
- public void addAlias(String alias, String path) throws KeyStoreException {
+ public void addAlias(String alias, String path) throws IOException, KeyStoreException {
Certificate cert = loadCertificate(path);
if (cert == null) {
return;
@@ -131,15 +131,19 @@ class KeyStoreHandler {
/**
* Try to load a certificate instance from given path.
*/
- private Certificate loadCertificate(String path) {
+ private Certificate loadCertificate(String path) throws IOException {
Certificate certificate = null;
+ FileInputStream in = null;
try {
- FileInputStream in = new FileInputStream(path);
+ in = new FileInputStream(path);
certificate = certFactory.generateCertificate(in);
- in.close();
} catch (Exception e) {
System.err.println("Warning: there was a problem reading the certificate file " +
path + ". Message:\n " + e.getMessage());
+ } finally {
+ if (in != null) {
+ in.close();
+ }
}
return certificate;
}
View it on GitLab: https://salsa.debian.org/java-team/ca-certificates-java/-/commit/429b952c7dac00ac9bcd9e89ec0456dab5bc7bfc
--
View it on GitLab: https://salsa.debian.org/java-team/ca-certificates-java/-/commit/429b952c7dac00ac9bcd9e89ec0456dab5bc7bfc
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20260325/e8906a6f/attachment.htm>
More information about the pkg-java-commits
mailing list