Skip to content
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

feat(bindings/java): convey backtrace on exception #3286

Merged
merged 3 commits into from
Oct 15, 2023

Conversation

tisonkun
Copy link
Member

@tisonkun tisonkun commented Oct 15, 2023

I'm not sure if it's better to expose a method said display(force_backtrace: bool) in opendal::Error.

Without backtrace, it's very hard to debug across binding (language) boundary.

Before -

org.apache.camel.FailedToCreateRouteException: Failed to create route route1: Route(route1)[From[opendal://foo] -> [To[opendal://bar], To[... because of Failed to resolve endpoint: opendal://foo due to: Unexpected (permanent) at  => Null pointer in get_object_class, source: Null pointer in get_object_class

	at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:82)
	at org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)

After with RUST_BACKTRACE=1 -

[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.479 s <<< FAILURE! -- in org.apache.opendal.test.OperatorInfoTest
[ERROR] org.apache.opendal.test.OperatorInfoTest.testOperatorInfo -- Time elapsed: 0.036 s <<< ERROR!
org.apache.opendal.OpenDALException: 
Unexpected (permanent) at  => Null pointer in get_string obj argument, source: Null pointer in get_string obj argument
Backtrace:
   0: std::backtrace_rs::backtrace::libunwind::trace
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1: std::backtrace_rs::backtrace::trace_unsynchronized
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2: std::backtrace::Backtrace::create
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/std/src/backtrace.rs:332:13
   3: opendal_java::error::Error::new
             at ./src/error.rs:38:24
   4: opendal_java::error::Error::unexpected
             at ./src/error.rs:43:9
   5: <opendal_java::error::Error as core::convert::From<jni::wrapper::errors::Error>>::from
             at ./src/error.rs:103:9
   6: <core::result::Result<T,F> as core::ops::try_trait::FromResidual<core::result::Result<core::convert::Infallible,E>>>::from_residual
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/result.rs:1961:27
   7: opendal_java::jstring_to_string
             at ./src/lib.rs:230:24
   8: opendal_java::operator::intern_constructor
             at ./src/operator.rs:56:35
   9: Java_org_apache_opendal_Operator_constructor
             at ./src/operator.rs:49:5


	at org.apache.opendal.Operator.constructor(Native Method)
	at org.apache.opendal.Operator.of(Operator.java:115)

Signed-off-by: tison <wander4096@gmail.com>
bindings/java/src/error.rs Outdated Show resolved Hide resolved
bindings/java/src/error.rs Outdated Show resolved Hide resolved
Signed-off-by: tison <wander4096@gmail.com>
@tisonkun
Copy link
Member Author

Updated.

@tisonkun tisonkun changed the title feat(bindings/java): always convey backtrace on exception feat(bindings/java): convey backtrace on exception Oct 15, 2023
Copy link
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Xuanwo Xuanwo merged commit 8539ccd into apache:main Oct 15, 2023
48 checks passed
@tisonkun tisonkun deleted the java-backtrace branch October 15, 2023 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants