All Downloads are FREE. Search and download functionalities are using the official Maven repository.

no.ssb.lds.api.persistence.Transaction Maven / Gradle / Ivy

There is a newer version: 0.13
Show newest version
package no.ssb.lds.api.persistence;

import java.util.concurrent.CompletableFuture;

public interface Transaction extends AutoCloseable {

    CompletableFuture commit();

    CompletableFuture cancel();

    @Override
    default void close() {
        boolean committed = false;
        try {
            commit().join();
            committed = true;
        } catch (Throwable t) {
            if (t instanceof RuntimeException) {
                throw (RuntimeException) t;
            }
            if (t instanceof Error) {
                throw (Error) t;
            }
            throw new RuntimeException(t);
        } finally {
            if (!committed) {
                cancel().join();
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy