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/04/04 16:45:32 UTC
[geode] branch develop updated: GEODE-4989 CQ reply message
fromData method deserializes query results
This is an automated email from the ASF dual-hosted git repository.
bschuchardt pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 3c263e9 GEODE-4989 CQ reply message fromData method deserializes query results
3c263e9 is described below
commit 3c263e9220cd56486e3ec4d39cdd0a694482fb49
Author: Bruce Schuchardt <bs...@pivotal.io>
AuthorDate: Wed Apr 4 09:43:50 2018 -0700
GEODE-4989 CQ reply message fromData method deserializes query results
CqEntry was using DataSerializer.readObject() to read the entry's value
instead of InternalDataSerializer.readUserObject(). The latter is needed
to respect the setting of pdx-read-serialized in the query service's
StreamingReplyMessage.
This closes #1719
---
.../apache/geode/cache/query/internal/CqEntry.java | 2 +-
.../internal/streaming/StreamingOperation.java | 8 +++---
.../apache/geode/pdx/internal/TypeRegistry.java | 6 +++++
.../QueryObjectSerializationJUnitTest.java | 30 +++++++++++++++++++++-
4 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CqEntry.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CqEntry.java
index fb01a07..9b09682 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CqEntry.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CqEntry.java
@@ -92,7 +92,7 @@ public class CqEntry implements DataSerializableFixedID {
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
this.key = InternalDataSerializer.readUserObject(in);
- this.value = DataSerializer.readObject(in);
+ this.value = InternalDataSerializer.readUserObject(in);
}
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/streaming/StreamingOperation.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/streaming/StreamingOperation.java
index 391c366..4cfba1d 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/streaming/StreamingOperation.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/streaming/StreamingOperation.java
@@ -554,17 +554,17 @@ public abstract class StreamingOperation {
lowMemoryDetected = true;
break;
}
- Object o = InternalDataSerializer.readUserObject(in);
+ Object theObject = DataSerializer.readObject(in);
if (isQueryMessageProcessor && elementType != null && elementType.isStructType()) {
boolean convertToStruct = isSenderAbove_8_1;
if (convertToStruct && i == 0) {
- convertToStruct = !(o instanceof PRQueryTraceInfo);
+ convertToStruct = !(theObject instanceof PRQueryTraceInfo);
}
if (convertToStruct) {
- o = new StructImpl((StructTypeImpl) elementType, (Object[]) o);
+ theObject = new StructImpl((StructTypeImpl) elementType, (Object[]) theObject);
}
}
- this.objectList.add(o);
+ this.objectList.add(theObject);
}
if (lowMemoryDetected) {
isCanceled = true;
diff --git a/geode-core/src/main/java/org/apache/geode/pdx/internal/TypeRegistry.java b/geode-core/src/main/java/org/apache/geode/pdx/internal/TypeRegistry.java
index 76aed3e..00a64b3 100644
--- a/geode-core/src/main/java/org/apache/geode/pdx/internal/TypeRegistry.java
+++ b/geode-core/src/main/java/org/apache/geode/pdx/internal/TypeRegistry.java
@@ -95,6 +95,12 @@ public class TypeRegistry {
}
}
+ /**
+ * When this returns true pdx-read-serialized should be respected, which is the
+ * default. Setting this to false disables pdx-read-serialized while deserializing
+ * objects. This takes precendence over setPdxReadSerializedOverride, which affects
+ * the cache's setting of that attribute.
+ */
public static boolean getPdxReadSerialized() {
return disablePdxReadSerialized.get() == null;
}
diff --git a/geode-core/src/test/java/org/apache/geode/cache/query/internal/QueryObjectSerializationJUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/query/internal/QueryObjectSerializationJUnitTest.java
index bf36757..e0dff0a 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/query/internal/QueryObjectSerializationJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/query/internal/QueryObjectSerializationJUnitTest.java
@@ -14,7 +14,7 @@
*/
package org.apache.geode.cache.query.internal;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -32,9 +32,14 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.apache.geode.DataSerializer;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.query.QueryService;
import org.apache.geode.cache.query.types.ObjectType;
+import org.apache.geode.distributed.ConfigurationProperties;
import org.apache.geode.internal.cache.CachePerfStats;
+import org.apache.geode.pdx.PdxSerializableDUnitTest;
+import org.apache.geode.pdx.internal.PdxInstanceImpl;
import org.apache.geode.test.junit.categories.UnitTest;
/**
@@ -132,6 +137,29 @@ public class QueryObjectSerializationJUnitTest implements Serializable {
// checkRoundTrip(sssWithoutData);
}
+ /**
+ * Ensure that a CqEntry respects pdx-read-serialized=true
+ */
+ @Test
+ public void testPdxReadSerializedWithCQEntry() throws IOException, ClassNotFoundException {
+ Cache cache = new CacheFactory().set(ConfigurationProperties.LOCATORS, "")
+ .set(ConfigurationProperties.MCAST_PORT, "0").setPdxReadSerialized(true).create();
+
+ try {
+ Object key = "APdxSerializableObject";
+ Object value = new PdxSerializableDUnitTest.TestPdxObject();
+ CqEntry entry = new CqEntry(key, value);
+ DataOutputStream out = getDataOutput();
+ DataSerializer.writeObject(entry, out);
+ out.flush();
+ DataInput in = getDataInput();
+ CqEntry newEntry = DataSerializer.readObject(in);
+ assertEquals(PdxInstanceImpl.class, newEntry.getValue().getClass());
+ } finally {
+ cache.close();
+ }
+ }
+
private static class SimpleObjectType implements ObjectType {
public SimpleObjectType() {}
--
To stop receiving notification emails like this one, please contact
bschuchardt@apache.org.