Skip to content
Permalink
Browse files
[BAHIR-172 ] Replace FileInputStream with Files.newInputStream (#92)
  • Loading branch information
liketic authored and lresende committed Sep 3, 2019
1 parent 549c50b commit 68ac1be22ddccecf105aee355a8c2652868e9f7d
Showing 2 changed files with 3 additions and 3 deletions.
@@ -18,9 +18,9 @@
package org.apache.bahir.sql.streaming.mqtt

import java.io.File
import java.io.FileInputStream
import java.net.{ServerSocket, URI}
import java.nio.charset.Charset
import java.nio.file.Files
import java.security.{KeyStore, SecureRandom}
import java.util.Properties
import javax.net.ssl.KeyManagerFactory
@@ -63,7 +63,7 @@ class MQTTTestUtils(tempDir: File, port: Int = 0, ssl: Boolean = false) extends
val protocol = if (ssl) "mqtt+ssl" else "mqtt"
if (ssl) {
val keyStore = KeyStore.getInstance("JKS")
keyStore.load(new FileInputStream(serverKeyStore), serverKeyStorePassword.toCharArray)
keyStore.load(Files.newInputStream(serverKeyStore.toPath), serverKeyStorePassword.toCharArray)
val keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm)
keyManagerFactory.init(keyStore, serverKeyStorePassword.toCharArray)
broker.setSslContext(
@@ -86,7 +86,7 @@ private[pubsub] final case class EMailPrivateKeyCredentials(
override def provider: Credential = {
val tempFile = File.createTempFile(emailAccount, ".p12")
tempFile.deleteOnExit()
val p12Out = new FileOutputStream(tempFile)
val p12Out = Files.newOutputStream(tempFile.toPath)
p12Out.write(p12Content, 0, p12Content.length)
p12Out.flush()
p12Out.close()

0 comments on commit 68ac1be

Please sign in to comment.