@Test (expected = RuntimeException.class) public void testTransactionWithoutInitAndClose() throws Exception { transaction.closeTransaction(); }
public void closeTransaction() { synchronized (transactionLock) { if (!transactionState.compareAndSet(TransactionState.STOPED, TransactionState.CLOSED) && !transactionState.compareAndSet(TransactionState.INIT, TransactionState.CLOSED)) { throw new RuntimeException("We are in transaction state, can not close this transaction"); } doCloseTransaction(); } }
Transaction { public void closeTransaction() { synchronized (transactionLock) { if (!transactionState.compareAndSet(TransactionState.STOPED, TransactionState.CLOSED) && !transactionState.compareAndSet(TransactionState.INIT, TransactionState.CLOSED)) { throw new RuntimeException("We are in transaction state, can not close this transaction"); } doCloseTransaction(); } } }
Transaction { public void closeTransaction() { synchronized (transactionLock) { if (!transactionState.compareAndSet(TransactionState.STOPED, TransactionState.CLOSED) && !transactionState.compareAndSet(TransactionState.INIT, TransactionState.CLOSED)) { throw new RuntimeException("We are in transaction state, can not close this transaction"); } doCloseTransaction(); } } protected  Transaction(); }
Transaction { public void closeTransaction() { synchronized (transactionLock) { if (!transactionState.compareAndSet(TransactionState.STOPED, TransactionState.CLOSED) && !transactionState.compareAndSet(TransactionState.INIT, TransactionState.CLOSED)) { throw new RuntimeException("We are in transaction state, can not close this transaction"); } doCloseTransaction(); } } protected  Transaction(); void initTransaction(); void startTransaction(); T take(); void commitTransaction(); void rollbackTransaction(); void closeTransaction(); }
Transaction { public void closeTransaction() { synchronized (transactionLock) { if (!transactionState.compareAndSet(TransactionState.STOPED, TransactionState.CLOSED) && !transactionState.compareAndSet(TransactionState.INIT, TransactionState.CLOSED)) { throw new RuntimeException("We are in transaction state, can not close this transaction"); } doCloseTransaction(); } } protected  Transaction(); void initTransaction(); void startTransaction(); T take(); void commitTransaction(); void rollbackTransaction(); void closeTransaction();  }