@@ -40,7 +40,9 @@ import cats.syntax.all._
40
40
import com .comcast .ip4s .{IpAddress , SocketAddress }
41
41
42
42
import java .util .function .BiFunction
43
- import java .nio .file .Path
43
+ import java .nio .file .{Path => JPath }
44
+
45
+ import fs2 .io .file .Path
44
46
45
47
private [tls] trait TLSContextPlatform [F [_]] {
46
48
@@ -104,6 +106,14 @@ private[tls] trait TLSContextCompanionPlatform { self: TLSContext.type =>
104
106
def insecure : F [TLSContext [F ]]
105
107
106
108
/** Creates a `TLSContext` from the specified key store file. */
109
+ @ deprecated(" Use overload that takes an fs2.io.file.Path instead" , " 3.13.0" )
110
+ def fromKeyStoreFile (
111
+ file : JPath ,
112
+ storePassword : Array [Char ],
113
+ keyPassword : Array [Char ]
114
+ ): F [TLSContext [F ]] =
115
+ fromKeyStoreFile(Path .fromNioPath(file), storePassword, keyPassword)
116
+
107
117
def fromKeyStoreFile (
108
118
file : Path ,
109
119
storePassword : Array [Char ],
@@ -275,7 +285,7 @@ private[tls] trait TLSContextCompanionPlatform { self: TLSContext.type =>
275
285
storePassword : Array [Char ],
276
286
keyPassword : Array [Char ]
277
287
): F [TLSContext [F ]] = {
278
- val load = Async [F ].blocking(new FileInputStream (file.toFile): InputStream )
288
+ val load = Async [F ].blocking(new FileInputStream (file.toNioPath. toFile): InputStream )
279
289
val stream = Resource .make(load)(s => Async [F ].blocking(s.close))
280
290
fromKeyStoreStream(stream, storePassword, keyPassword)
281
291
}
@@ -285,7 +295,11 @@ private[tls] trait TLSContextCompanionPlatform { self: TLSContext.type =>
285
295
storePassword : Array [Char ],
286
296
keyPassword : Array [Char ]
287
297
): F [TLSContext [F ]] = {
288
- val load = Async [F ].blocking(getClass.getClassLoader.getResourceAsStream(resource))
298
+ val load = Async [F ].blocking {
299
+ val s = getClass.getClassLoader.getResourceAsStream(resource)
300
+ if (s eq null ) throw new IOException (s " Classpath resource not found [ $resource] " )
301
+ else s
302
+ }
289
303
val stream = Resource .make(load)(s => Async [F ].blocking(s.close))
290
304
fromKeyStoreStream(stream, storePassword, keyPassword)
291
305
}
0 commit comments