This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new f9b05cdd5 fix(bindings/java): bring back false delete code (#5752)
f9b05cdd5 is described below

commit f9b05cdd5b5681cd3d85165656dae2552863ee78
Author: yihong <[email protected]>
AuthorDate: Wed Mar 12 15:54:18 2025 +0800

    fix(bindings/java): bring back false delete code (#5752)
---
 bindings/java/src/executor.rs | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/bindings/java/src/executor.rs b/bindings/java/src/executor.rs
index 9ddedbd24..0d7e28b1e 100644
--- a/bindings/java/src/executor.rs
+++ b/bindings/java/src/executor.rs
@@ -33,7 +33,7 @@ use tokio::task::JoinHandle;
 
 use crate::Result;
 
-static RUNTIME: OnceLock<Executor> = OnceLock::new();
+static mut RUNTIME: OnceLock<Executor> = OnceLock::new();
 thread_local! {
     static ENV: RefCell<Option<*mut jni::sys::JNIEnv>> = const { 
RefCell::new(None) };
 }
@@ -41,8 +41,11 @@ thread_local! {
 /// # Safety
 ///
 /// This function could be only called by java vm when unload this lib.
+#[allow(static_mut_refs)]
 #[no_mangle]
-pub unsafe extern "system" fn JNI_OnUnload(_: JavaVM, _: *mut c_void) {}
+pub unsafe extern "system" fn JNI_OnUnload(_: JavaVM, _: *mut c_void) {
+    RUNTIME.take();
+}
 
 /// # Safety
 ///
@@ -183,6 +186,7 @@ pub(crate) fn executor_or_default<'a>(
 /// # Safety
 ///
 /// This function could be only when the lib is loaded.
+#[allow(static_mut_refs)]
 unsafe fn default_executor<'a>(env: &mut JNIEnv<'a>) -> Result<&'a Executor> {
     // Return the executor if it's already initialized
     if let Some(runtime) = RUNTIME.get() {

Reply via email to