geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bogle...@apache.org
Subject [geode] 01/01: GEODE-5917: Modified instanceof to check for CachedDeserializable instead of VMCachedDeserializable
Date Fri, 26 Oct 2018 19:13:17 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 86f7921268c93dea38681c58d6faa633b32abc17
Author: Barry Oglesby <boglesby@pivotal.io>
AuthorDate: Fri Oct 26 12:10:58 2018 -0700

    GEODE-5917: Modified instanceof to check for CachedDeserializable instead of VMCachedDeserializable
---
 .../geode/cache/query/dunit/PDXQueryTestBase.java  |  2 +-
 .../geode/cache/query/dunit/PdxQueryDUnitTest.java | 41 ++++++++++++++++++++++
 .../geode/cache/query/internal/utils/PDXUtils.java |  5 +--
 3 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/PDXQueryTestBase.java
b/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/PDXQueryTestBase.java
index 47036df..84817ab 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/PDXQueryTestBase.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/PDXQueryTestBase.java
@@ -196,7 +196,7 @@ public abstract class PDXQueryTestBase extends JUnit4CacheTestCase {
   }
 
   protected void configAndStartBridgeServer(boolean isPr, boolean isAccessor) {
-    configAndStartBridgeServer(false, false, false, null);
+    configAndStartBridgeServer(isPr, isAccessor, false, null);
   }
 
   protected void configAndStartBridgeServer(boolean isPr, boolean isAccessor, boolean asyncIndex,
diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/PdxQueryDUnitTest.java
b/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/PdxQueryDUnitTest.java
index 59e1bee..e87d67d 100644
--- a/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/PdxQueryDUnitTest.java
+++ b/geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/PdxQueryDUnitTest.java
@@ -15,6 +15,7 @@
 package org.apache.geode.cache.query.dunit;
 
 import static org.apache.geode.internal.Assert.fail;
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -1481,6 +1482,46 @@ public class PdxQueryDUnitTest extends PDXQueryTestBase {
     this.closeClient(vm0);
   }
 
+  @Test
+  public void testPdxReadSerializedForPRSelectAllQuery() throws CacheException {
+    VM vm0 = VM.getVM(0);
+    VM vm1 = VM.getVM(1);
+
+    final int numPuts = 10;
+
+    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
+      public void run2() throws CacheException {
+        configAndStartBridgeServer(true, false);
+        GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
+        cache.setReadSerializedForTest(true);
+      }
+    });
+
+    vm1.invoke(new CacheSerializableRunnable("Create Bridge Server") {
+      public void run2() throws CacheException {
+        configAndStartBridgeServer(true, false);
+        GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
+        cache.setReadSerializedForTest(true);
+      }
+    });
+
+    vm0.invoke(() -> {
+      Region region = getRootRegion().getSubregion(regionName);
+      for (int i = 0; i < numPuts; i++) {
+        region.put("key-" + i, new TestObject(i, "val-" + i));
+      }
+    });
+
+    vm0.invoke(() -> {
+      QueryService qs = getCache().getQueryService();
+      Query query = qs.newQuery(queryString[1]);
+      SelectResults sr = (SelectResults) query.execute();
+      assertThat(sr.size()).isEqualTo(numPuts);
+      for (Object result : sr) {
+        assertThat(result).isInstanceOf(PdxInstance.class);
+      }
+    });
+  }
 
   /**
    * Tests index on PdxInstance.
diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/utils/PDXUtils.java
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/utils/PDXUtils.java
index 6ca3782..f9df944 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/utils/PDXUtils.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/utils/PDXUtils.java
@@ -16,6 +16,7 @@ package org.apache.geode.cache.query.internal.utils;
 
 import org.apache.geode.cache.CacheException;
 import org.apache.geode.cache.query.internal.StructImpl;
+import org.apache.geode.internal.cache.CachedDeserializable;
 import org.apache.geode.internal.cache.VMCachedDeserializable;
 import org.apache.geode.pdx.PdxInstance;
 import org.apache.geode.pdx.internal.PdxString;
@@ -79,8 +80,8 @@ public class PDXUtils {
         obj = ((PdxString) obj).toString();
       }
 
-      if (getDeserializedObject && obj instanceof VMCachedDeserializable) {
-        obj = ((VMCachedDeserializable) obj).getDeserializedForReading();
+      if (getDeserializedObject && obj instanceof CachedDeserializable) {
+        obj = ((CachedDeserializable) obj).getDeserializedForReading();
         objectChangedMarker[0] = true;
       }
 


Mime
View raw message