Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-5443 NPE in ReadCommittedEntry.getLifespan() during Cache.size()
* Fixed issue with RR when calling size when entry was not found in same * transaction
- Loading branch information
Showing
4 changed files
with
137 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
core/src/test/java/org/infinispan/api/APIRepeatableReadTxTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.infinispan.api; | ||
|
||
import org.infinispan.configuration.cache.ConfigurationBuilder; | ||
import org.infinispan.manager.EmbeddedCacheManager; | ||
import org.infinispan.test.fwk.TestCacheManagerFactory; | ||
import org.infinispan.util.concurrent.IsolationLevel; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* @author William Burns | ||
* @since 7.2 | ||
*/ | ||
@Test (groups = "functional", testName = "api.APIRepeatableReadTxTest") | ||
public class APIRepeatableReadTxTest extends APITxTest { | ||
|
||
@Override | ||
protected EmbeddedCacheManager createCacheManager() throws Exception { | ||
// start a single cache instance | ||
ConfigurationBuilder c = getDefaultStandaloneCacheConfig(true); | ||
c.locking().isolationLevel(IsolationLevel.REPEATABLE_READ); | ||
EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(false); | ||
cm.defineConfiguration("test", c.build()); | ||
cache = cm.getCache("test"); | ||
return cm; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package org.infinispan.api; | ||
|
||
import org.infinispan.configuration.cache.ConfigurationBuilder; | ||
import org.infinispan.manager.EmbeddedCacheManager; | ||
import org.infinispan.test.TestingUtil; | ||
import org.infinispan.test.fwk.TestCacheManagerFactory; | ||
import org.testng.annotations.Test; | ||
|
||
import javax.transaction.NotSupportedException; | ||
import javax.transaction.SystemException; | ||
import javax.transaction.TransactionManager; | ||
|
||
import static org.testng.AssertJUnit.assertEquals; | ||
|
||
/** | ||
* @author William Burns | ||
* @since 7.2 | ||
*/ | ||
@Test (groups = "functional", testName = "api.APITxTest") | ||
public class APITxTest extends APINonTxTest { | ||
|
||
@Override | ||
protected EmbeddedCacheManager createCacheManager() throws Exception { | ||
// start a single cache instance | ||
ConfigurationBuilder c = getDefaultStandaloneCacheConfig(true); | ||
EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(false); | ||
cm.defineConfiguration("test", c.build()); | ||
cache = cm.getCache("test"); | ||
return cm; | ||
} | ||
|
||
public void testSizeInExplicitTxWithNonExistent() throws SystemException, NotSupportedException { | ||
assertEquals(0, cache.size()); | ||
cache.put("k", "v"); | ||
|
||
TransactionManager tm1 = TestingUtil.getTransactionManager(cache); | ||
tm1.begin(); | ||
try { | ||
cache.get("no-exist"); | ||
assertEquals(1, cache.size()); | ||
cache.put("no-exist", "value"); | ||
assertEquals(2, cache.size()); | ||
} finally { | ||
tm1.rollback(); | ||
} | ||
} | ||
|
||
public void testSizeInExplicitTxWithRemoveNonExistent() throws SystemException, NotSupportedException { | ||
assertEquals(0, cache.size()); | ||
cache.put("k", "v"); | ||
|
||
TransactionManager tm1 = TestingUtil.getTransactionManager(cache); | ||
tm1.begin(); | ||
try { | ||
cache.remove("no-exist"); | ||
assertEquals(1, cache.size()); | ||
cache.put("no-exist", "value"); | ||
assertEquals(2, cache.size()); | ||
} finally { | ||
tm1.rollback(); | ||
} | ||
} | ||
|
||
public void testSizeInExplicitTxWithRemoveExistent() throws SystemException, NotSupportedException { | ||
assertEquals(0, cache.size()); | ||
cache.put("k", "v"); | ||
|
||
TransactionManager tm1 = TestingUtil.getTransactionManager(cache); | ||
tm1.begin(); | ||
try { | ||
cache.put("exist", "value"); | ||
assertEquals(2, cache.size()); | ||
cache.remove("exist"); | ||
assertEquals(1, cache.size()); | ||
} finally { | ||
tm1.rollback(); | ||
} | ||
} | ||
|
||
public void testSizeInExplicitTx() throws SystemException, NotSupportedException { | ||
assertEquals(0, cache.size()); | ||
cache.put("k", "v"); | ||
|
||
TransactionManager tm1 = TestingUtil.getTransactionManager(cache); | ||
tm1.begin(); | ||
try { | ||
assertEquals(1, cache.size()); | ||
} finally { | ||
tm1.rollback(); | ||
} | ||
} | ||
|
||
public void testSizeInExplicitTxWithModification() throws SystemException, NotSupportedException { | ||
assertEquals(0, cache.size()); | ||
cache.put("k1", "v1"); | ||
|
||
TransactionManager tm1 = TestingUtil.getTransactionManager(cache); | ||
tm1.begin(); | ||
try { | ||
cache.put("k2", "v2"); | ||
assertEquals(2, cache.size()); | ||
} finally { | ||
tm1.rollback(); | ||
} | ||
} | ||
} |