An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

        

# FortEE

[![Build Status](https://travis-ci.org/Pscheidl/FortEE.svg?branch=master)](https://travis-ci.org/Pscheidl/FortEE)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/cab8a9609a9a4362a18c1ff3f759cf02)](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
```xml

com.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");
}

}
```