https://github.com/pscheidl/fortee
Jakarta EE / Java EE fault-tolerance guard leveraging the Optional pattern. Its power lies in its simplicity.
https://github.com/pscheidl/fortee
annotations cdi-extension fault-tolerance jakartaee java javaee simplicity
Last synced: 6 days ago
JSON representation
Jakarta EE / Java EE fault-tolerance guard leveraging the Optional pattern. Its power lies in its simplicity.
- Host: GitHub
- URL: https://github.com/pscheidl/fortee
- Owner: Pscheidl
- License: mit
- Created: 2017-04-07T05:03:07.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-03-01T17:37:37.000Z (about 1 year ago)
- Last Synced: 2025-04-04T04:12:44.624Z (about 2 months ago)
- Topics: annotations, cdi-extension, fault-tolerance, jakartaee, java, javaee, simplicity
- Language: Java
- Homepage:
- Size: 163 KB
- Stars: 12
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FortEE
[](https://travis-ci.org/Pscheidl/FortEE)
[](https://www.codacy.com/app/pavel.junior/FortEE?utm_source=github.com&utm_medium=referral&utm_content=Pscheidl/FortEE&utm_campaign=Badge_Grade)FortEE is a Jakarta EE / Java EE fault-tolerance guard leveraging the Optional pattern. Its power lies in its simplicity. On methods returning Optional, a @Failsafe annotation can be placed. Any uncaught exceptional states are then converted into an Optional.empty(). Synchronous or asynchronous invocation is not enforced.
- Simple and fast
- Startup-time check
- Tiny in size
- Compatible with Jakarta EE 8, requires Java EE 7## Maven
```xmlcom.github.pscheidl
fortee
1.2.0```
## Gradle
```groovy
compile 'com.github.pscheidl:fortee:1.2.0'
```
**Release notes**
- Released on 14th of June 2020
- The `@Semisafe` annotation ignored exceptions not only listed as a value of that annotation,
but also exceptions directly specified in the mehod's definition, e.g. `public Optional doSomething() throws UnsupportedOperationException` will let the
`UnsupportedOperationException` through.
- Test suite ran against WildFly 20.0.0-Final.## How it works ?
For more information, please visit [FortEE wikipedia](https://github.com/Pscheidl/FortEE/wiki).
Guard against all checked and unchecked exceptions.
```java
@Named
public class ServiceImplementation implements SomeService {// Will return Optional.empty()
@Failsafe
public Optional maybeFail(){
throw new RuntimeException("Failed on purpose");
}}
```Guard against all exceptions but the declared ones, or the ones listed in the `@Semisafe` annotation..
```java
@Named
public class ServiceImplementation implements SomeService {// Will end with RuntimeException
@Semisafe
public Optional maybeFail() throws RuntimeException {
throw new RuntimeException("Failed on purpose");
}}
```Alternatively, the exception to be let through can be specified inside the `@Semisafe` annotation.
```java
@Named
public class ServiceImplementation implements SomeService {// Will end with RuntimeException
@Semisafe({RuntimeException.class})
public Optional maybeFail(){
throw new RuntimeException("Failed on purpose");
}}
```