-
Notifications
You must be signed in to change notification settings - Fork 129
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
Checked Exceptions are not causing a failure event #529
Comments
Oh, I didn't know that about Kotlin. Any Kotlin user that knows the type of exception thrown in this case. CC @jponge |
Oh, BTW, the second line should be:
|
Ok so in Kotlin there is no notion of checked exception, and when you throw a This actually makes sense, because a supplier cannot throw a checked exception, so you can't write this in Java: Multi<Integer> multi = Multi.createFrom().item(() -> {
throw new Exception("boom");
}); ...but this is fine for Kotlin which is more permissive here. |
I'm tempted to say this is not a bug, because in Java you can't have this, this is specific to Kotlin and its laxer type checking wrt exception control flow. |
Java has made "sneaky throws" really easy -- here's my favorite implementation: public class SneakyThrow {
private SneakyThrow() {
}
/**
* This method can and should be used as part of a {@code throw} statement,
* such as: {@code throw sneakyThrow(exception);}. It is guaranteed to never return normally,
* and this style of usage makes sure that the Java compiler is aware of that.
*/
@SuppressWarnings("unchecked")
public static <E extends Throwable> RuntimeException sneakyThrow(Throwable e) throws E {
throw (E) e;
}
} So you can have this in Java, really easily: |
Yes this is evilish @Ladicek 😆 |
So it's interesting, perhaps we need to catch better "just in case" |
I'm looking into it. |
I opened #534 to fix that. |
Thanks @ferencbeutel4711 for reporting |
hey guys, thank you so much for the quick fix! |
It will be part of 0.17, we tend to release about once a month, then it's upgraded in Quarkus. |
Hi,
If a checked exception is thrown inside of a .item() - handler, it does not cause a failure event.
kotlin example
The above uni will never print the error (and pretty sure it will also never terminate, since this issue caused deadlocks in our application). If a RuntimeException is thrown, everything is fine.
The text was updated successfully, but these errors were encountered: