{"record":{"id":"603e0c6740b25adf","repo":"risingwavelabs/risingwave","slug":"anyhow-e-603e0c","errorCode":null,"errorMessage":"anyhow!(e)","messagePattern":"anyhow!\\(e\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/jni_core/src/opendal_schema_history.rs","lineNumber":123,"sourceCode":"                Arc::new(ObjectStoreConfig::default()),\n            )\n            .await;\n            Arc::new(object_store)\n        })\n        .await\n        .clone()\n}\n\n/// Initialize `STATE_STORE_URL` and `DATA_DIRECTORY` for integration tests.\n/// Must be called before any schema history operations if compute node is not running.\n#[unsafe(no_mangle)]\npub extern \"system\" fn Java_com_risingwave_java_binding_Binding_initObjectStoreForTest(\n    env: EnvParam<'_>,\n    state_store_url: JString<'_>,\n    data_directory: JString<'_>,\n) {\n    execute_and_catch(env, move |env| {\n        let state_store_url_str = env.get_string(&state_store_url).map_err(|e| anyhow!(e))?;\n        let state_store_url_str: Cow<'_, str> = (&state_store_url_str).into();\n\n        let data_directory_str = env.get_string(&data_directory).map_err(|e| anyhow!(e))?;\n        let data_directory_str: Cow<'_, str> = (&data_directory_str).into();\n\n        // Set the global variables (only if not already set)\n        let _ = STATE_STORE_URL.set(state_store_url_str.to_string());\n        let _ = DATA_DIRECTORY.set(data_directory_str.to_string());\n\n        Ok(())\n    });\n}\n\n#[unsafe(no_mangle)]\npub extern \"system\" fn Java_com_risingwave_java_binding_Binding_putObject(\n    env: EnvParam<'_>,\n    object_name: JString<'_>,\n    data: JByteArray<'_>,","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/jni_core/src/opendal_schema_history.rs#L105-L141","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nBinding.initObjectStoreForTest(null, \"/data\"); // anyhow!(e) thrown\n// after\nString url = stateStoreUrl != null ? stateStoreUrl : \"memory\";\nBinding.initObjectStoreForTest(url, \"/data\");","handlingStrategy":"validation","validationCode":"// Java, before initObjectStoreForTest\nObjects.requireNonNull(stateStoreUrl, \"state_store_url must not be null\");","typeGuard":"// Java\nstatic boolean validUrlArg(String s) {\n    return s != null && !s.isEmpty();\n}","tryCatchPattern":"try {\n    Binding.initObjectStoreForTest(url, dir);\n} catch (RuntimeException e) {\n    // thrown report wraps the jni get_string failure\n    throw new IllegalStateException(\"failed to init object store: \" + e.getMessage(), e);\n}","preventionTips":["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"],"tags":["jni","string","null","object-store"],"backgroundTag":"null-argument","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}