Merge pull request #47 from CommentSectionScientist/UseTryWithResources

Use try with resources when handling FileStreams
This commit is contained in:
Marc Mültin 2020-05-02 13:45:36 +02:00 committed by GitHub
commit 3ec641f05d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -1008,9 +1008,9 @@ public final class SecurityUtils {
getCertificateChain(contractCertChain));
// Save the keystore persistently
FileOutputStream fos = new FileOutputStream("evccKeystore.jks");
keyStore.store(fos, GlobalValues.PASSPHRASE_FOR_CERTIFICATES_AND_KEYS.toString().toCharArray());
fos.close();
try(FileOutputStream fos = new FileOutputStream("evccKeystore.jks")){
keyStore.store(fos, GlobalValues.PASSPHRASE_FOR_CERTIFICATES_AND_KEYS.toString().toCharArray());
}
X509Certificate contractCert = getCertificate(contractCertChain.getCertificate());