geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From esh...@apache.org
Subject [geode] branch develop updated: GEODE-6315: Handle null in comparison in a compressed offheap region (#3115)
Date Fri, 25 Jan 2019 18:24:38 GMT
This is an automated email from the ASF dual-hosted git repository.

eshu11 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 425eb59  GEODE-6315: Handle null in comparison in a compressed offheap region (#3115)
425eb59 is described below

commit 425eb59a3c1cbbadb5d82d7466798f8b00e0c691
Author: pivotal-eshu <eshu@pivotal.io>
AuthorDate: Fri Jan 25 10:24:26 2019 -0800

    GEODE-6315: Handle null in comparison in a compressed offheap region (#3115)
---
 .../geode/internal/cache/ValueComparisonHelper.java      |  6 +++---
 .../geode/internal/cache/ValueComparisonHelperTest.java  | 16 ++++++++++++++++
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/ValueComparisonHelper.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/ValueComparisonHelper.java
index 285e8e5..2315701 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/ValueComparisonHelper.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/ValueComparisonHelper.java
@@ -227,6 +227,9 @@ public class ValueComparisonHelper {
     }
     Object cdVal = cd.getValue();
     if (cdVal instanceof byte[]) {
+      if (obj == null || obj == Token.NOT_AVAILABLE || Token.isInvalidOrRemoved(obj)) {
+        return false;
+      }
       byte[] cdValBytes = (byte[]) cdVal;
       PdxInstance pi = InternalDataSerializer.readPdxInstance(cdValBytes, cache);
       if (pi != null) {
@@ -250,9 +253,6 @@ public class ValueComparisonHelper {
         if (obj instanceof CachedDeserializable) {
           deserializedObj = ((CachedDeserializable) obj).getDeserializedForReading();
         } else {
-          if (obj == null || obj == Token.NOT_AVAILABLE || Token.isInvalidOrRemoved(obj))
{
-            return false;
-          }
           // TODO OPTIMIZE: Before serializing all of obj we could get the top
           // level class name of cdVal and compare it to the top level class name of obj.
           deserializedObj = obj;
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/ValueComparisonHelperTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/ValueComparisonHelperTest.java
index 830ff7f..b39ea8d 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/ValueComparisonHelperTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/ValueComparisonHelperTest.java
@@ -509,6 +509,10 @@ public class ValueComparisonHelperTest {
         ValueComparisonHelper.checkEquals(cachedDeserializable, null, false,
             mock(InternalCache.class)))
                 .isFalse();
+    assertThat(
+        ValueComparisonHelper.checkEquals(cachedDeserializable, null, true,
+            mock(InternalCache.class)))
+                .isFalse();
   }
 
   @Test
@@ -521,6 +525,10 @@ public class ValueComparisonHelperTest {
         ValueComparisonHelper.checkEquals(cachedDeserializable, Token.NOT_AVAILABLE, false,
             mock(InternalCache.class)))
                 .isFalse();
+    assertThat(
+        ValueComparisonHelper.checkEquals(cachedDeserializable, Token.NOT_AVAILABLE, true,
+            mock(InternalCache.class)))
+                .isFalse();
   }
 
   @Test
@@ -537,6 +545,14 @@ public class ValueComparisonHelperTest {
         ValueComparisonHelper.checkEquals(cachedDeserializable, Token.LOCAL_INVALID, false,
             mock(InternalCache.class)))
                 .isFalse();
+    assertThat(
+        ValueComparisonHelper.checkEquals(cachedDeserializable, Token.INVALID, true,
+            mock(InternalCache.class)))
+                .isFalse();
+    assertThat(
+        ValueComparisonHelper.checkEquals(cachedDeserializable, Token.LOCAL_INVALID, true,
+            mock(InternalCache.class)))
+                .isFalse();
   }
 
   @Test


Mime
View raw message