You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When Promise.fail(Throwable) or Promise.fail(String) are called with an already completed Promise the reason for why those methods are called can be lost. Using Promise.tryFail(Throwable) and Promise.tryFail(String) can prevent the exception from being thrown by Promise but if the fail methods are being used they should at least include the cause for the exception being thrown.
Ex:
Change
defaultvoidfail(Throwablecause) {
if (!tryFail(cause)) {
thrownewIllegalStateException("Result is already complete");
}
}
to
defaultvoidfail(Throwablecause) {
if (!tryFail(cause)) {
thrownewIllegalStateException("Result is already complete", cause);
}
}
This will at least retain the cause information if the exception thrown isn't handled appropriately.
Use cases
Loss of information when an error occurs.
Contribution
I'd be happy to contribute if this change is deemed appropriate.
The text was updated successfully, but these errors were encountered:
I am not sure using it as cause is the right thing to do, since both are not related directly, the cause on the illegal state exception could be misleading in logs.
Instead something like a PromiseAlreadyCompletedException extending IllegalStateException could used with an optional object that is the completion (which is the result or a failure). Users might want to know about the same with complete(T) and wonder which object triggered a success completion.
Was mostly looking to see if there was an improvement that could be done in this area for code, which I'm basing on my code where I had a corner case where this exception was thrown, where information wasn't lost. I was able to root cause and fix my code to handle this more gracefully, but the reason for why this issue triggered I still don't know as there wasn't a way to grab the first Promise.cause due to the structure of my code.
Describe the feature
When
Promise.fail(Throwable)
orPromise.fail(String)
are called with an already completedPromise
the reason for why those methods are called can be lost. UsingPromise.tryFail(Throwable)
andPromise.tryFail(String)
can prevent the exception from being thrown byPromise
but if thefail
methods are being used they should at least include the cause for the exception being thrown.Ex:
Change
to
This will at least retain the
cause
information if the exception thrown isn't handled appropriately.Use cases
Loss of information when an error occurs.
Contribution
I'd be happy to contribute if this change is deemed appropriate.
The text was updated successfully, but these errors were encountered: