Skip to content

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

Merged
Xuanwo merged 3 commits intoapache:mainfrom
tisonkun:java-backtrace
Oct 15, 2023
Merged

feat(bindings/java): convey backtrace on exception#3286
Xuanwo merged 3 commits intoapache:mainfrom
tisonkun:java-backtrace

Conversation

@tisonkun
Copy link
Copy Markdown
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>
@github-actions github-actions Bot added the releases-note/feat The PR implements a new feature or has a title that begins with "feat" label Oct 15, 2023
Comment thread bindings/java/src/error.rs Outdated
Comment thread bindings/java/src/error.rs Outdated
Signed-off-by: tison <wander4096@gmail.com>
@tisonkun
Copy link
Copy Markdown
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
Copy Markdown
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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

releases-note/feat The PR implements a new feature or has a title that begins with "feat"

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants