-
Notifications
You must be signed in to change notification settings - Fork 594
fix: drop useless import and clippy happy for java binding #5746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: yihong0618 <[email protected]>
In which PR we bump MSRV? I remember @Xuanwo suppose to hold on that the last time. |
Signed-off-by: yihong0618 <[email protected]>
bindings/java/src/executor.rs
Outdated
@@ -43,7 +43,9 @@ thread_local! { | |||
/// This function could be only called by java vm when unload this lib. | |||
#[no_mangle] | |||
pub unsafe extern "system" fn JNI_OnUnload(_: JavaVM, _: *mut c_void) { | |||
let _ = RUNTIME.take(); | |||
// Since OnceLock doesn't have a take() method, we can't remove the runtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I'm not sure about this https://doc.rust-lang.org/stable/std/sync/struct.OnceLock.html#method.take
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will fix it
Signed-off-by: yihong0618 <[email protected]>
Signed-off-by: yihong0618 <[email protected]>
Signed-off-by: yihong0618 <[email protected]>
bindings/java/src/executor.rs
Outdated
@@ -43,7 +43,8 @@ thread_local! { | |||
/// This function could be only called by java vm when unload this lib. | |||
#[no_mangle] | |||
pub unsafe extern "system" fn JNI_OnUnload(_: JavaVM, _: *mut c_void) { | |||
let _ = RUNTIME.take(); | |||
// This is fine as the JVM is shutting down anyway |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, please don't change this unless we have good reasons.
bindings/java/src/executor.rs
Outdated
// It's okay if another thread initialized it first | ||
let _ = RUNTIME.set(executor); | ||
|
||
// Now RUNTIME should be initialized | ||
Ok(RUNTIME.get().ok_or_else(|| { | ||
opendal::Error::new( | ||
opendal::ErrorKind::Unexpected, | ||
"Failed to initialize default executor", | ||
) | ||
}) | ||
})?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can use get_or_init
here to save an extra error check:
Ok(RUNTIME.get_or_init(|| executor))
Signed-off-by: yihong0618 <[email protected]>
|
bindings/java/src/executor.rs
Outdated
// It's okay if another thread initialized it first | ||
let _ = RUNTIME.set(executor); | ||
|
||
// Now RUNTIME should be initialized | ||
Ok(RUNTIME.get().ok_or_else(|| { | ||
opendal::Error::new( | ||
opendal::ErrorKind::Unexpected, | ||
"Failed to initialize default executor", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// It's okay if another thread initialized it first | |
let _ = RUNTIME.set(executor); | |
// Now RUNTIME should be initialized | |
Ok(RUNTIME.get().ok_or_else(|| { | |
opendal::Error::new( | |
opendal::ErrorKind::Unexpected, | |
"Failed to initialize default executor", | |
Ok(RUNTIME.get_or_init(|| executor)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if Rust corelib has a get_or_try_init
. Or else we can add one ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: yihong0618 <[email protected]>
is this way lose error message? |
Error handling happen at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great now, thank you @yihong0618
learned thanks |
Hi, @yihong0618 I just noticed that this PR removed the |
seems we can not use it here will take a look |
Hi, I don't think it's fine. We know it works good before and I don't want to change here without good reasons. |
yes you are right, will dig into it |
Which issue does this PR close?
Closes #5745
This patch do these things for java binding:
Replace once_cell::sync::OnceCell with the standard library's std::sync::OnceLock (available since Rust 1.70)