risingwavelabs/risingwave · error
anyhow!(e)
Error message
anyhow!(e)
What it means
In Java_com_risingwave_java_binding_Binding_initObjectStoreForTest, the result of env.get_string(&state_store_url) is mapped with anyhow!(e) because the surrounding closure must return anyhow-compatible errors. It throws when the JNI string extraction for the state_store_url parameter fails (null input, invalid reference, or pending Java exception). The error is then converted by execute_and_catch into a thrown Java exception.
Solutions
- Pass a non-null, valid java.lang.String state store URL (e.g. "memory" or "s3://...") from the Java side
- Null-check the argument in Java before calling the binding
- Check for and clear any pending Java exception before the native call
- Inspect the thrown Java exception message: it reports the inner jni::errors::Error from get_string
Example fix
// before Binding.initObjectStoreForTest(null, "/data"); // anyhow!(e) thrown // after String url = stateStoreUrl != null ? stateStoreUrl : "memory"; Binding.initObjectStoreForTest(url, "/data");
Defensive patterns
Strategy: validation
Validate before calling
// Java, before initObjectStoreForTest Objects.requireNonNull(stateStoreUrl, "state_store_url must not be null");
Type guard
// Java
static boolean validUrlArg(String s) {
return s != null && !s.isEmpty();
} Try / catch
try {
Binding.initObjectStoreForTest(url, dir);
} catch (RuntimeException e) {
// thrown report wraps the jni get_string failure
throw new IllegalStateException("failed to init object store: " + e.getMessage(), e);
} Prevention
- Never pass null Strings to JNI bindings
- Default missing config values on the Java side before the call
- Clear pending exceptions before native entry
- Keep native method signatures in sync with Java declarations
When it happens
Trigger: Calling Binding.initObjectStoreForTest(null, dir) or passing a non-String object / stale JString reference for the first argument; a Java exception is already pending on the thread when the native call begins.
Common situations: Java test harness passes null URL when the state store config was not loaded; type mismatch in the Java native-method signature after refactoring; JVM thread already in exception state.
Related errors
- StorageError
- anyhow!(err_msg)
- backup job failed: job
- Caught Java Exception
- check if version hint exist failed
AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11).
Data as JSON: /api/errors/603e0c6740b25adf.
Report an issue: GitHub.
Appendix: source
Thrown at src/jni_core/src/opendal_schema_history.rs:123
Arc::new(ObjectStoreConfig::default()),
)
.await;
Arc::new(object_store)
})
.await
.clone()
}
/// Initialize `STATE_STORE_URL` and `DATA_DIRECTORY` for integration tests.
/// Must be called before any schema history operations if compute node is not running.
#[unsafe(no_mangle)]
pub extern "system" fn Java_com_risingwave_java_binding_Binding_initObjectStoreForTest(
env: EnvParam<'_>,
state_store_url: JString<'_>,
data_directory: JString<'_>,
) {
execute_and_catch(env, move |env| {
let state_store_url_str = env.get_string(&state_store_url).map_err(|e| anyhow!(e))?;
let state_store_url_str: Cow<'_, str> = (&state_store_url_str).into();
let data_directory_str = env.get_string(&data_directory).map_err(|e| anyhow!(e))?;
let data_directory_str: Cow<'_, str> = (&data_directory_str).into();
// Set the global variables (only if not already set)
let _ = STATE_STORE_URL.set(state_store_url_str.to_string());
let _ = DATA_DIRECTORY.set(data_directory_str.to_string());
Ok(())
});
}
#[unsafe(no_mangle)]
pub extern "system" fn Java_com_risingwave_java_binding_Binding_putObject(
env: EnvParam<'_>,
object_name: JString<'_>,
data: JByteArray<'_>,View on GitHub (pinned to 6469eb736d)