From 94fb22e050d77c16dc05adb1c5c2af305e171406 Mon Sep 17 00:00:00 2001 From: Bugen Zhao Date: Wed, 28 Feb 2024 18:15:48 +0800 Subject: [PATCH] simplify validation Signed-off-by: Bugen Zhao --- src/jni_core/src/jvm_runtime.rs | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/jni_core/src/jvm_runtime.rs b/src/jni_core/src/jvm_runtime.rs index b52ea04976fd0..4af5e5d3563a3 100644 --- a/src/jni_core/src/jvm_runtime.rs +++ b/src/jni_core/src/jvm_runtime.rs @@ -63,30 +63,14 @@ impl JavaVmWrapper { } else { tracing::info!("environment variable CONNECTOR_LIBS_PATH is not specified, use default path `./libs` instead"); std::env::current_exe() - .and_then(|p| p.fs_err_canonicalize()) + .and_then(|p| p.fs_err_canonicalize()) // resolve symlink of the current executable .context("unable to get path of the executable")? .parent() .expect("not root") .join("libs") }; - let libs_path = libs_path - .fs_err_canonicalize() - .context("invalid path for connector libs")?; - - if !libs_path.exists() { - bail!( - "CONNECTOR_LIBS_PATH \"{}\" does not exist", - libs_path.display() - ); - } - if !libs_path.is_dir() { - bail!( - "CONNECTOR_LIBS_PATH \"{}\" is not a directory", - libs_path.display() - ); - } - + // No need to validate the path now, as it will be further checked when calling `fs::read_dir` later. Ok(libs_path) }