ultm icon indicating copy to clipboard operation
ultm copied to clipboard

No commit/rollback on `Error`

Open witoldsz opened this issue 7 years ago • 0 comments

The ThreadLocalTxManager has this method:

    @Override
    public <T> T txUnwrappedResult(UnitOfWorkCall<T> unit) throws Exception {
        begin();
        try {
            T result = unit.call();
            commit();
            return result;
        } catch (Exception e) {
            rollback();
            throw e;
        }
    }

Trouble is when unit throws an Error (for example: JUnit test with fail). The connection will not be released, there will be no commit or rollback.

In my very case, next test after the one which was calling fail was hanging forever because of this.

I think we need a finally clause here.

witoldsz avatar Jun 21 '18 17:06 witoldsz