From 954fc0d73ed050b3a76084e49f77b2d561c3f24b Mon Sep 17 00:00:00 2001 From: wforget <643348094@qq.com> Date: Thu, 28 Nov 2024 18:23:05 +0800 Subject: [PATCH] [MINOR] Avoid NPE when native lib is not found --- .../apache/spark/sql/blaze/BlazeCallNativeWrapper.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spark-extension/src/main/scala/org/apache/spark/sql/blaze/BlazeCallNativeWrapper.scala b/spark-extension/src/main/scala/org/apache/spark/sql/blaze/BlazeCallNativeWrapper.scala index 18054c67..292185cd 100644 --- a/spark-extension/src/main/scala/org/apache/spark/sql/blaze/BlazeCallNativeWrapper.scala +++ b/spark-extension/src/main/scala/org/apache/spark/sql/blaze/BlazeCallNativeWrapper.scala @@ -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 {