commit | 8dbd0d6f57d3d79a1888c2c640a953343adee9b6 | [log] [tgz] |
---|---|---|
author | Lin Sun <linsun@apache.org> | Wed Dec 03 02:50:40 2008 +0000 |
committer | Lin Sun <linsun@apache.org> | Wed Dec 03 02:50:40 2008 +0000 |
tree | 038e03e3dd0bf8ab21b21e33dcdbb826bce4186a | |
parent | 1571a01e83219f45e7d8fb3e51e99a19314f6cb7 [diff] |
GERONIMO-4438 - TransactionSynchronizationRegistry.getTransactionKey should return null when transaction is not associated with the current thread git-svn-id: https://svn.apache.org/repos/asf/geronimo/components/txmanager/trunk@722724 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java b/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java index 1a0f324..59309de 100644 --- a/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java +++ b/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java
@@ -205,8 +205,8 @@ } public Object getTransactionKey() { - TransactionImpl tx = getActiveTransactionImpl(); - return tx.getTransactionKey(); + TransactionImpl tx = (TransactionImpl) getTransaction(); + return tx == null ? null: tx.getTransactionKey(); } public int getTransactionStatus() {
diff --git a/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/TransactionSynchronizationRegistryTest.java b/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/TransactionSynchronizationRegistryTest.java index 0b311a5..46b9355 100644 --- a/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/TransactionSynchronizationRegistryTest.java +++ b/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/TransactionSynchronizationRegistryTest.java
@@ -57,6 +57,15 @@ tm.getTransaction().registerSynchronization(normalSync); } + public void testTransactionKey() throws Exception { + normalSync = new CountingSync(); + assertNull(tm.getTransactionKey()); + setUpInterposedSync(); + tm.getTransaction().registerSynchronization(normalSync); + assertNotNull(tm.getTransactionKey()); + tm.commit(); + assertNull(tm.getTransactionKey()); + } public void testInterposedSynchIsCalledOnCommit() throws Exception { setUpInterposedSync();