Close resource as we cannot inline (#3125)

Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/3125

Better stream creation and disposal.

A report was generated with the following error:
StrictMode policy violation: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.

Changelog: Close input stream after use which was causing strict mode policy violation crashes and possibly leaking resources.

Reviewed By: passy

Differential Revision: D32830690

fbshipit-source-id: de3ffaf1b600590c4060a381fae66e73e08745cb
This commit is contained in:
Lorenzo Blasa
2021-12-03 12:56:09 -08:00
committed by Facebook GitHub Bot
parent b7a29ac0b3
commit 2d89c2f3eb

View File

@@ -87,7 +87,9 @@ class FlipperSocketImpl extends WebSocketClient implements FlipperSocket {
String cert_client_pass = authenticationObject.getString("certificates_client_pass");
String cert_ca_path = authenticationObject.getString("certificates_ca_path");
ks.load(new FileInputStream(cert_client_path), cert_client_pass.toCharArray());
try (InputStream clientCertificateStream = new FileInputStream(cert_client_path)) {
ks.load(clientCertificateStream, cert_client_pass.toCharArray());
}
KeyManagerFactory kmf =
KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());