Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1718 [created] d492a5831


fix replace on overflowed entry


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/d492a583
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/d492a583
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/d492a583

Branch: refs/heads/feature/GEODE-1718
Commit: d492a58316c6c939eaba73e804bca5d15778cefe
Parents: 59e4c44
Author: Darrel Schneider <dschnei...@pivotal.io>
Authored: Mon Aug 1 16:12:38 2016 -0700
Committer: Darrel Schneider <dschnei...@pivotal.io>
Committed: Mon Aug 1 16:12:38 2016 -0700

----------------------------------------------------------------------
 .../internal/cache/AbstractRegionEntry.java     |  2 +-
 .../internal/cache/AbstractRegionMap.java       |  2 +-
 .../cache/ReplaceWithOverflowJUnitTest.java     | 77 ++++++++++++++++++++
 3 files changed, 79 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d492a583/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
 
b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
index 15a5bed..5778a82 100644
--- 
a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
+++ 
b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionEntry.java
@@ -1072,7 +1072,7 @@ public abstract class AbstractRegionEntry implements 
RegionEntry,
           obj = cdVal;
         }
       }
-      if (obj.getClass().getName().equals(pdx.getClassName())) {
+      if (obj != null && obj.getClass().getName().equals(pdx.getClassName())) {
         GemFireCacheImpl gfc = GemFireCacheImpl.getForPdx("Could not access 
Pdx registry");
         if (gfc != null) {
           PdxSerializer pdxSerializer;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d492a583/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
 
b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
index f3cb3d6..87b59cd 100644
--- 
a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
+++ 
b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
@@ -2811,7 +2811,7 @@ public abstract class AbstractRegionMap implements 
RegionMap {
     if (expectedOldValue != null && !replaceOnClient) {
       ReferenceCountHelper.skipRefCountTracking();
       
-      @Retained @Released Object v = 
re._getValueRetain(event.getLocalRegion(), true);
+      @Retained @Released Object v = 
re.getValueOffHeapOrDiskWithoutFaultIn(event.getLocalRegion());
       
       ReferenceCountHelper.unskipRefCountTracking();
       try {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d492a583/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ReplaceWithOverflowJUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ReplaceWithOverflowJUnitTest.java
 
b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ReplaceWithOverflowJUnitTest.java
new file mode 100644
index 0000000..b796d6d
--- /dev/null
+++ 
b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ReplaceWithOverflowJUnitTest.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.internal.cache;
+
+import java.util.Properties;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import static org.junit.Assert.assertEquals;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.EvictionAction;
+import com.gemstone.gemfire.cache.EvictionAttributes;
+import com.gemstone.gemfire.cache.PartitionAttributesFactory;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionFactory;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Test the replace method with an entry that has overflowed to disk.
+ */
+@Category(IntegrationTest.class)
+public class ReplaceWithOverflowJUnitTest {
+
+  private Cache cache;
+
+  @Before
+  public void setUp() {
+    Properties props = new Properties();
+    props.setProperty("mcast-port", "0");
+    props.setProperty("log-level", "info");
+    cache = new CacheFactory(props).create();
+  }
+  
+  @After
+  public void tearDown() {
+    if(cache != null && !cache.isClosed()) {
+      cache.close();
+    }
+  }
+  @Test
+  public void testReplaceWithOverflow() throws InterruptedException { 
+    Region region = createRegion();
+    region.put("1", "1");
+    region.put("2", "2");
+    assertEquals(true, region.replace("1", "1", "one"));
+    
+  }
+
+  private Region createRegion() {
+    RegionFactory<Object, Object> rf = cache.createRegionFactory()
+        .setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1, 
EvictionAction.OVERFLOW_TO_DISK))
+        .setPartitionAttributes(new 
PartitionAttributesFactory().setTotalNumBuckets(1).create())
+        .setDataPolicy(DataPolicy.PARTITION);
+    Region region = rf
+        .create("ReplaceWithOverflowJUnitTest");
+    return region;
+  }
+}

Reply via email to