-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#16455] java.lang.Error should rollback the JTA transaction
- Loading branch information
Showing
2 changed files
with
34 additions
and
11 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...sions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/SneakyThrow.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.quarkus.narayana.jta.runtime; | ||
|
||
/** | ||
* An utility class which makes possible to throw any exception as a {@link RuntimeException}. | ||
* It means to throw checked exception (subtype of Throwable or Exception) as un-checked exception. | ||
* This considers the Java 8 inference rule that states that a {@code throws E} is inferred as {@code RuntimeException}. | ||
*/ | ||
public class SneakyThrow { | ||
private SneakyThrow() { | ||
throw new IllegalStateException("utility class, do not create an instance"); | ||
} | ||
|
||
/** | ||
* This method can be used in {@code throw} statement | ||
* such as: {@code throw sneakyThrow(exception);}. | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
public static <E extends Throwable> void sneakyThrow(Throwable e) throws E { | ||
throw (E) e; | ||
} | ||
} |
This file contains 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