@Override public void run() { /* * Note: This invokes the tx.abort() without regard to whether or * not the connection is open (it will be closed since we closed * it before submitting this for execution). */ synchronized (remoteTx) { final IRemoteTx tx = remoteTx.get(); if (tx != null) { try { tx.abort(); } catch (RuntimeException e) { // Log and ignore. log.error(e, e); } catch (Exception e) { // Log and ignore. log.error(e, e); } finally { // Clear the reference since we are closing the conn. remoteTx.set(null/* newValue */); } } } } });
@Override public void rollback() throws RepositoryException { assertOpen(); // non-blocking. synchronized (remoteTx) { assertOpen(); // non-blocking. final IRemoteTx tx = remoteTx.get(); if (tx != null) { try { tx.abort(); remoteTx.set(null/* newValue */); } catch (RemoteTransactionNotFoundException e) { throw new UnknownTransactionStateException(e); } catch (Exception e) { throw new UnknownTransactionStateException(e); } } } }
/** * Create an unisolated transaction, verify its metadata, and abort it. */ public void test_CREATE_TX_UNISOLATED_01() throws Exception { assertNotNull(m_mgr); assertNotNull(m_mgr.getTransactionManager()); final IRemoteTx tx = m_mgr.getTransactionManager().createTx( RemoteTransactionManager.UNISOLATED); try { assertTrue(tx.isActive()); assertFalse(tx.isReadOnly()); } finally { tx.abort(); } assertFalse(tx.isActive()); assertFalse(tx.isReadOnly()); }
/** * Create an read-only transaction, verify its metadata, and abort it. */ public void test_CREATE_TX_READ_ONLY_01() throws Exception { assertNotNull(m_mgr); assertNotNull(m_mgr.getTransactionManager()); final IRemoteTx tx = m_mgr.getTransactionManager().createTx( RemoteTransactionManager.READ_COMMITTED); try { assertTrue(tx.isActive()); assertTrue(tx.isReadOnly()); } finally { tx.abort(); } assertFalse(tx.isActive()); assertTrue(tx.isReadOnly()); }
/** * Create an unisolated transaction, verify its metadata, and abort it. */ public void test_CREATE_TX_UNISOLATED_01() throws Exception { assertNotNull(m_mgr); assertNotNull(m_mgr.getTransactionManager()); final IRemoteTx tx = m_mgr.getTransactionManager().createTx( RemoteTransactionManager.UNISOLATED); try { assertTrue(tx.isActive()); assertFalse(tx.isReadOnly()); } finally { tx.abort(); } assertFalse(tx.isActive()); assertFalse(tx.isReadOnly()); }
/** * Create an read-only transaction, verify its metadata, and abort it. */ public void test_CREATE_TX_READ_ONLY_01() throws Exception { assertNotNull(m_mgr); assertNotNull(m_mgr.getTransactionManager()); final IRemoteTx tx = m_mgr.getTransactionManager().createTx( RemoteTransactionManager.READ_COMMITTED); try { assertTrue(tx.isActive()); assertTrue(tx.isReadOnly()); } finally { tx.abort(); } assertFalse(tx.isActive()); assertTrue(tx.isReadOnly()); }