[Junie]: Junie Tracing reports a swallowed CancellationException warning#6
Open
junie-eap[bot] wants to merge 2 commits intomainfrom
Open
[Junie]: Junie Tracing reports a swallowed CancellationException warning#6junie-eap[bot] wants to merge 2 commits intomainfrom
junie-eap[bot] wants to merge 2 commits intomainfrom
Conversation
… warning changes from the task: #5
|
@jetbrains-junie add java-doc for the function you created |
Author
|
Hey, it’s Junie by JetBrains! I started processing your request 🚀 |
summary: JavaDoc was successfully added to the function, clearly explaining its purpose, parameters, return value, and exceptions. The implementation is error-free, and all tests passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Hey! This PR was made for you with Junie, the coding agent by JetBrains Early Access Preview
It's still learning, developing, and might make mistakes. Please make sure you review the changes before you accept them.
We’d love your feedback — join our Discord to share bugs, ideas: here.
📝 Original Issue Description
I am writing a simple helper for Arrow Core that introduces a Raise context in which failures throw AssertionError, with the goal of using it to simplify writing tests. Since this helper would only be used in automated tests that are expected not to fail, enabling tracing by default seems reasonable as it helps understand the root cause, so the performance impact is worth it.
Using the following code:
@ExperimentalTraceApi$error\n$ {trace.stackTraceToString()}")
inline fun <Failure, Success> failOnRaise(block: Raise.() -> Success): Success {
val result = either {
traced(block) { trace, error ->
throw AssertionError("An operation raised
.apply {
for (suppressed in trace.suppressedExceptions())
addSuppressed(suppressed)
}
}
}
}
// In the test
failOnRaise {
raise(5)
}
I would expect this example to throw:
AssertionError: An operation raised
5arrow.core.raise.Traced: // some normal exception trace
But, instead, it throws:
java.lang.AssertionError: An operation raised 5
arrow.core.raise.Traced: kotlin.coroutines.cancellation.CancellationException should never get swallowed. Always re-throw it if captured.This swallows the exception of Arrow's Raise, and leads to unexpected behavior.When working with Arrow prefer Either.catch or arrow.core.raise.catch to automatically rethrow CancellationException.
at arrow.core.raise.DefaultRaise.raise(Fold.kt:270)
at opensavvy.prepared.compat.arrow.core.FailOnRaiseTest$1$3.invokeSuspend(FailOnRaiseTest.kt:21)
Is it indented that this is the error message generated by traced? If so, it's bit too worrying to be normal behavior. If not, is there something wrong on my end?
📊 Junie Summary
The
failOnRaisefunction was updated to usefolddirectly, allowingCancellationExceptionto be rethrown while raising anAssertionErrorfor other errors. This resolves the warning about swallowing exceptions. The implementation is error-free, and all tests passed successfully.