ultm
ultm copied to clipboard
No commit/rollback on `Error`
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.