You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bs...@apache.org on 2018/08/27 18:29:40 UTC

[geode] 03/04: GEODE-5596 Client ends up with destroyed entry after invalidate()

This is an automated email from the ASF dual-hosted git repository.

bschuchardt pushed a commit to branch feature/GEODE-5596
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 0bcb01992ce4e0d20e285541b0975965106efe10
Author: Bruce Schuchardt <bs...@pivotal.io>
AuthorDate: Mon Aug 27 11:23:56 2018 -0700

    GEODE-5596 Client ends up with destroyed entry after invalidate()
    
    Fixing failing tests.  The behavior in clients has changed now - if
    there is no entry or a tombstone entry in the client and it does an
    invalidate() we now expect it to create an entry if concurrency-checks
    are enabled.
    
    I also changed the AttributesFactory javadoc for
    concurrency-checks-enabled because it was saying it is turned off by
    default but that is not the case.
---
 .../org/apache/geode/cache/AttributesFactory.java  |  2 +-
 .../sockets/ClientServerMiscDUnitTestBase.java     | 31 ++++++++--------------
 2 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/cache/AttributesFactory.java b/geode-core/src/main/java/org/apache/geode/cache/AttributesFactory.java
index 2017cf2..93d9a99 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/AttributesFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/AttributesFactory.java
@@ -193,7 +193,7 @@ import org.apache.geode.internal.i18n.LocalizedStrings;
  * others will only read. <br>
  * {@link #setConcurrencyLevel} {@link RegionAttributes#getConcurrencyLevel}</dd>
  *
- * <dt>ConcurrencyChecksEnabled [<em>default:</em> {@code false}]</dt>
+ * <dt>ConcurrencyChecksEnabled [<em>default:</em> {@code true}]</dt>
  * <dd>Enables a distributed versioning algorithm that detects concurrency conflicts in regions and
  * ensures that changes to an entry are not applied in a different order in other members. This can
  * cause operations to be conflated, so that some cache listeners may see an event while others do
diff --git a/geode-dunit/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientServerMiscDUnitTestBase.java b/geode-dunit/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientServerMiscDUnitTestBase.java
index 20d10ea..3bd42ca 100755
--- a/geode-dunit/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientServerMiscDUnitTestBase.java
+++ b/geode-dunit/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientServerMiscDUnitTestBase.java
@@ -16,6 +16,7 @@ package org.apache.geode.internal.cache.tier.sockets;
 
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -45,6 +46,7 @@ import org.apache.geode.cache.CacheException;
 import org.apache.geode.cache.CacheWriterException;
 import org.apache.geode.cache.DataPolicy;
 import org.apache.geode.cache.EntryEvent;
+import org.apache.geode.cache.InterestResultPolicy;
 import org.apache.geode.cache.PartitionAttributesFactory;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionAttributes;
@@ -554,27 +556,16 @@ public class ClientServerMiscDUnitTestBase extends JUnit4CacheTestCase {
     Region region = static_cache.getRegion(REGION_NAME1);
     populateCache();
     region.put("invalidationKey", "invalidationValue");
+
     region.localDestroy("invalidationKey");
-    if (region.containsKey("invalidationKey")) {
-      fail("region still contains invalidationKey");
-    }
+    assertThat(region.containsKey("invalidationKey")).isFalse();
+
     region.invalidate("invalidationKey");
-    if (region.containsKey("invalidationKey")) {
-      fail(
-          "this test expects the entry is not created on invalidate() if not there before the operation");
-    }
+    assertThat(region.containsKey("invalidationKey")).isTrue();
+
     Object value = region.get("invalidationKey");
-    if (value != null) {
-      fail("this test expected a null response to get('invalidationKey')");
-    }
-    if (!region.containsKeyOnServer("invalidationKey")) {
-      fail("expected an entry on the server after invalidation");
-    }
-    // bug 43407 asserts that there should be an entry, but the product does not
-    // do this. This verifies that the product does not behave as asserted in that bug
-    if (region.containsKey("invalidationKey")) {
-      fail("expected no entry after invalidation when entry was not in client but was on server");
-    }
+    assertThat(value).isNull();
+    assertThat(region.containsKeyOnServer("invalidationKey")).isTrue();
   }
 
   /**
@@ -986,8 +977,8 @@ public class ClientServerMiscDUnitTestBase extends JUnit4CacheTestCase {
       assertNotNull(r1);
       Region r2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
       assertNotNull(r2);
-      r1.registerInterest("ALL_KEYS", false, false);
-      r2.registerInterest("ALL_KEYS", false, false);
+      r1.registerInterestForAllKeys(InterestResultPolicy.KEYS, false, false);
+      r2.registerInterestForAllKeys(InterestResultPolicy.KEYS, false, false);
     } catch (CacheWriterException e) {
       e.printStackTrace();
       fail("Test failed due to CacheWriterException during registerInterestnBothRegions" + e);