question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Version 1.1.0 breaks referential equality of thrown exceptions

See original GitHub issue

When the flag kotlinx.coroutines.stacktrace.recovery is set to true, as per the default, exceptions thrown within the library are mutated or cloned so they lose referential equality properties.

We found this regression in Arrow when updating our adapter module to 1.1.0. We run a test suite that included some referential equality tests in this version. These referential equality tests were removed in the update process, as you can see in master. At least another library was affected, Vert.x, as stated here.

Even if this one fix could be applied to keep the Arrow adapter and Vert.x releases going, there is merit to the discussion of avoiding different behaviors between debug and production, and breaking a property that’s respected by other concurrency libraries such as Project Reactor, RxJava, Scalaz, and Scala/Cats.

An alternative like Throwable#addSuppressed doesn’t break referential equality, even if it mutates the exception. Defaulting to false and making the environment variable more visible in the documentation is another viable alternative 😄

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:10
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
fvascocommented, Jan 9, 2019

@pakoito Type Classes have to be linked at build time, it cannot become a pluggable solution.

As alternative solution, it is possible to provide an external component to rebuild the right stack trace, so we does not have to reinstantiate the Throwable. Having this external mechanism, it is possible to log the right stack trace when coroutine fails, then throwing the original exception. This solution does not alter the execution flow and it fills the log with debugging information. Finally it is possible to provide something like fun Throwable.coroutineStackTrace() for developing purpose.

2reactions
qwwdfsadcommented, Jan 9, 2019

What we can do is to provide some way to indicate that exception is non-copyable or to instruct kotlinx.coroutines how to copy particular exception class.

We can either introduce a global settable state (global functions like disableCloning(exceptionClazz) etc.) or marker interfaces that exception class should implement. The former introduces a global settable state and may have conflicts between multiple libraries, but can be used with classes that you cannot change, while the latter is more intrusive for the application/library code.

I am open to discuss other solutions or concerns about proposed ones.

Read more comments on GitHub >

github_iconTop Results From Across the Web

InvalidOperationException Class (System) - Microsoft Learn
The exception that is thrown when a method call is invalid for the object's current state.
Read more >
Throwing Exceptions (legacy) · Hug61B - joshhug
You try to call a method using a reference variable that is equal to null. You try to access index -1 of an...
Read more >
Compose Runtime - Android Developers
androidx.compose.runtime:runtime-*:1.3.0 is released. Version 1.3.0 contains these commits. Important changes since 1.2.0. Exception Handling / Live Edit ...
Read more >
Log4j – Changes - Apache Logging Services
Allow Plugins to be injected with the LoggerContext reference. ... Throw better exception message when both log4j-slf4j-impl and ...
Read more >
More Assertions
Availability: Linux, Windows, Mac; since version 1.1.0. ... terminates (except by throwing an exception) in an expected fashion is also a death test....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found