This is an automated email from the ASF dual-hosted git repository. nnag pushed a commit to branch support/1.15 in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/support/1.15 by this push: new 4be1a15f37 Revert "GEODE-10294: Compare invalid token during putIfAbsent retry. (#7679)" (#7704) 4be1a15f37 is described below commit 4be1a15f37afa678198984a578e15f4df3c26da9 Author: Nabarun Nag <nabarun...@users.noreply.github.com> AuthorDate: Thu May 19 09:11:47 2022 -0700 Revert "GEODE-10294: Compare invalid token during putIfAbsent retry. (#7679)" (#7704) This reverts commit 4f4af2a303142729708a951cc8a93f562c3de8bc. (cherry picked from commit b84d9c7f9423a1f2ec6b9932b32fd2e330a322ac) --- .../apache/geode/internal/cache/map/RegionMapPut.java | 14 +++----------- .../geode/internal/cache/map/RegionMapPutTest.java | 17 +++-------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/map/RegionMapPut.java b/geode-core/src/main/java/org/apache/geode/internal/cache/map/RegionMapPut.java index 8ff9db123b..e0b62a5976 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/map/RegionMapPut.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/map/RegionMapPut.java @@ -409,7 +409,9 @@ public class RegionMapPut extends AbstractRegionMapPut { event.isPossibleDuplicate()) { Object retainedValue = getRegionEntry().getValueRetain(getOwner()); try { - if (isSameValueAlreadyInCacheForPutIfAbsent(retainedValue)) { + if (ValueComparisonHelper.checkEquals(retainedValue, + getEvent().getRawNewValue(), + isCompressedOffHeap(event), getOwner().getCache())) { if (logger.isDebugEnabled()) { logger.debug("retried putIfAbsent found same value already in cache " + "- allowing the operation. entry={}; event={}", getRegionEntry(), @@ -428,16 +430,6 @@ public class RegionMapPut extends AbstractRegionMapPut { return true; } - private boolean isSameValueAlreadyInCacheForPutIfAbsent(Object retainedValue) { - if (Token.isInvalid(retainedValue)) { - return getEvent().getRawNewValue() == null || Token.isInvalid(getEvent().getRawNewValue()); - } - - return ValueComparisonHelper.checkEquals(retainedValue, - getEvent().getRawNewValue(), - isCompressedOffHeap(getEvent()), getOwner().getCache()); - } - private boolean isCompressedOffHeap(EntryEventImpl event) { return event.getRegion().getAttributes().getOffHeap() diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/map/RegionMapPutTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/map/RegionMapPutTest.java index 8b3d77e062..7fceaeb43a 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/map/RegionMapPutTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/map/RegionMapPutTest.java @@ -137,7 +137,7 @@ public class RegionMapPutTest { public void doesNotSetEventOldValueIfRetriedPutIfAbsentOperation() { final byte[] bytes = new byte[] {1, 2, 3, 4, 5}; givenExistingRegionEntry(); - when(existingRegionEntry.getValueRetain(internalRegion)).thenReturn(bytes); + when(existingRegionEntry.getValue()).thenReturn(bytes); when(internalRegion.getConcurrencyChecksEnabled()).thenReturn(true); givenPutIfAbsentOperation(bytes); // duplicate operation doPut(); @@ -145,22 +145,11 @@ public class RegionMapPutTest { assertThat(instance.isOverwritePutIfAbsent()).isTrue(); } - @Test - public void doesNotSetEventOldValueIfRetriedPutIfAbsentOperationOfNull() { - givenExistingRegionEntry(); - when(existingRegionEntry.getValueRetain(internalRegion)).thenReturn(Token.INVALID); - when(internalRegion.getConcurrencyChecksEnabled()).thenReturn(true); - givenPutIfAbsentOperation(null); // duplicate operation - doPut(); - verify(event).setOldValue(null, true); - assertThat(instance.isOverwritePutIfAbsent()).isTrue(); - } - @Test public void overWritePutIfAbsentIsTrueIfRetriedPutIfAbsentOperationHavingValidVersionTag() { final byte[] bytes = new byte[] {1, 2, 3, 4, 5}; givenExistingRegionEntry(); - when(existingRegionEntry.getValueRetain(internalRegion)).thenReturn(bytes); + when(existingRegionEntry.getValue()).thenReturn(bytes); when(internalRegion.getConcurrencyChecksEnabled()).thenReturn(true); givenPutIfAbsentOperation(bytes); // duplicate operation when(event.hasValidVersionTag()).thenReturn(true); @@ -173,7 +162,7 @@ public class RegionMapPutTest { private void givenPutIfAbsentOperation(byte[] bytes) { when(event.isPossibleDuplicate()).thenReturn(true); - when(event.getRawNewValue()).thenReturn(bytes); + when(event.basicGetNewValue()).thenReturn(bytes); when(event.getOperation()).thenReturn(Operation.PUT_IF_ABSENT); when(event.hasValidVersionTag()).thenReturn(false); ifNew = true;