DonalEvans commented on a change in pull request #5925:
URL: https://github.com/apache/geode/pull/5925#discussion_r561329417
##########
File path:
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/RegionConcurrentOperationDUnitTest.java
##########
@@ -131,6 +140,49 @@ public void
getOnPreLoadedRegionFromMultipleThreadsReturnSameObject() throws Exc
assertThat(cacheRule.getCache().getRegion(regionName).size()).isEqualTo(1);
}
+ @Test
+ public void
getOnPartitionedRegionFromMultipleThreadsReturnsDifferentPdxInstances()
+ throws Exception {
+ String regionName = getClass().getSimpleName();
+ CacheFactory cacheFactory = new CacheFactory();
+ cacheFactory.setPdxReadSerialized(true);
+ cacheRule.createCache(cacheFactory);
+ InternalCache cache = cacheRule.getCache();
+ cache.setCopyOnRead(true);
+ Region region = cache.createRegionFactory(PARTITION)
Review comment:
The compiler warning here (and elsewhere in the file) can be avoided by
using `Region<Object, Object>`.
##########
File path:
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/RegionConcurrentOperationDUnitTest.java
##########
@@ -131,6 +140,49 @@ public void
getOnPreLoadedRegionFromMultipleThreadsReturnSameObject() throws Exc
assertThat(cacheRule.getCache().getRegion(regionName).size()).isEqualTo(1);
}
+ @Test
+ public void
getOnPartitionedRegionFromMultipleThreadsReturnsDifferentPdxInstances()
+ throws Exception {
+ String regionName = getClass().getSimpleName();
+ CacheFactory cacheFactory = new CacheFactory();
+ cacheFactory.setPdxReadSerialized(true);
+ cacheRule.createCache(cacheFactory);
+ InternalCache cache = cacheRule.getCache();
+ cache.setCopyOnRead(true);
+ Region region = cache.createRegionFactory(PARTITION)
+ .create(regionName);
+
+ // Keep doing this concurrency test for 30 seconds.
+ long endTime = Duration.ofSeconds(30).toMillis() +
System.currentTimeMillis();
+
+ while (System.currentTimeMillis() < endTime) {
+ Callable<Object> getValue = () -> {
+ while (true) {
+ Object value = region.get(key);
+ if (value != null) {
+ return value;
+ }
+ }
+ };
+
+ // In this test, two threads are doing gets. One thread puts the value
+ // We expect that the threads will *always* get different PdxInstance
values
+ Future get1 = executorServiceRule.submit(getValue);
+ Future get2 = executorServiceRule.submit(getValue);
+ Future put = executorServiceRule.submit(() -> region.put(key, new
TestValue()));
Review comment:
Compiler warnings here (and elsewhere in the file) can be avoided by
using `Future<Object>`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]