Skip to content

Commit

Permalink
[MINOR] Avoid NPE when native lib is not found (#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
wForget authored Nov 28, 2024
1 parent f038f82 commit 0b3fb9f
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,11 @@ object BlazeCallNativeWrapper extends Logging {
val tempFile = File.createTempFile("libblaze-", ".tmp")
tempFile.deleteOnExit()

Utils.tryWithResource(classLoader.getResourceAsStream(libName)) { is =>
Utils.tryWithResource {
val is = classLoader.getResourceAsStream(libName)
assert(is != null, s"cannot load $libName")
Files.copy(is, tempFile.toPath, StandardCopyOption.REPLACE_EXISTING)
}
is
}(Files.copy(_, tempFile.toPath, StandardCopyOption.REPLACE_EXISTING))
System.load(tempFile.getAbsolutePath)

} catch {
Expand Down

0 comments on commit 0b3fb9f

Please sign in to comment.