This is an automated email from the ASF dual-hosted git repository. zhouxj pushed a commit to branch feature/GEODE-5890 in repository https://gitbox.apache.org/repos/asf/geode.git
commit 481b46f671f98466b7b759a9440b95feb1c1c9c4 Author: zhouxh <[email protected]> AuthorDate: Fri Oct 19 14:27:56 2018 -0700 GEODE-5890: a cleaner fix to skip calling GatewayConflictResolver if tag has the same distributed system id. --- .../apache/geode/internal/cache/entries/AbstractRegionEntry.java | 8 +++++++- .../geode/internal/cache/entries/AbstractRegionEntryTest.java | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/entries/AbstractRegionEntry.java b/geode-core/src/main/java/org/apache/geode/internal/cache/entries/AbstractRegionEntry.java index fdadea0..1d728e3 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/entries/AbstractRegionEntry.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/entries/AbstractRegionEntry.java @@ -2073,8 +2073,14 @@ public abstract class AbstractRegionEntry implements HashRegionEntry<Object, Obj if (tagTime == VersionTag.ILLEGAL_VERSION_TIMESTAMP) { return true; // no timestamp received from other system - just apply it } + // According to GatewayConflictResolver's java doc, it will only be used on tag with different + // distributed system id than stamp's if ((tagDsid == stampDsid && tagTime > stampTime) || stampDsid == -1) { - return true; + if (tagTime > stampTime) { + return true; + } else { + throw new ConcurrentCacheModificationException("conflicting WAN event detected"); + } } GatewayConflictResolver resolver = event.getRegion().getCache().getGatewayConflictResolver(); if (resolver != null) { diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/entries/AbstractRegionEntryTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/entries/AbstractRegionEntryTest.java index 21ed680..04a98c2 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/entries/AbstractRegionEntryTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/entries/AbstractRegionEntryTest.java @@ -29,7 +29,9 @@ import java.io.IOException; import org.assertj.core.api.Assertions; import org.junit.Assert; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.apache.geode.DataSerializer; import org.apache.geode.cache.query.QueryException; @@ -58,6 +60,9 @@ import org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap.Ha public class AbstractRegionEntryTest { + @Rule + public ExpectedException expectedException = ExpectedException.none(); + @Test public void whenMakeTombstoneHasSetValueThatThrowsExceptionDoesNotChangeValueToTombstone() throws RegionClearedException { @@ -118,7 +123,7 @@ public class AbstractRegionEntryTest { } } - @Test(expected = ConcurrentCacheModificationException.class) + @Test public void gatewayEventsFromSameDSShouldThrowCMEIfMisordered() { // create 2 gateway events with the same dsid, but different timestamp // apply them in misorder, it should throw CME @@ -149,6 +154,8 @@ public class AbstractRegionEntryTest { // apply tag1 with smaller timestamp should throw CME entryEvent1.setVersionTag(tag1); + expectedException.expect(ConcurrentCacheModificationException.class); + expectedException.expectMessage("conflicting WAN event detected"); re.processVersionTag(entryEvent1); }
