Skip to content

Commit 9f59985

Browse files
committed
Use use to close stream automatically
1 parent e8d4f9a commit 9f59985

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/src/test/java/at/bitfire/cert4android/CustomCertManagerTest.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,12 @@ class CustomCertManagerTest {
114114
SecureRandom()
115115
)
116116
}.socketFactory
117-
conn.inputStream.read()
118-
val certs = mutableListOf<X509Certificate>()
119-
conn.serverCertificates.forEach { certs += it as X509Certificate }
120-
return certs
117+
conn.inputStream.use {
118+
it.read()
119+
val certs = mutableListOf<X509Certificate>()
120+
conn.serverCertificates.forEach { certs += it as X509Certificate }
121+
return certs
122+
}
121123
} finally {
122124
conn.disconnect()
123125
}

0 commit comments

Comments
 (0)