cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdeggles...@apache.org
Subject [1/6] cassandra git commit: Fix NPE when performing comparison against a null frozen in LWT
Date Thu, 08 Mar 2018 23:57:12 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 d7740052f -> 2c150980c
  refs/heads/cassandra-3.11 c87dc1ae7 -> 620f37c54
  refs/heads/trunk a7141e6c9 -> dd409898c


Fix NPE when performing comparison against a null frozen in LWT

Patch by Kurt Greaves; Reviewed by Blake Eggleston for CASSANDRA-14087


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/2c150980
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/2c150980
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/2c150980

Branch: refs/heads/cassandra-3.0
Commit: 2c150980cc1bfea81fd039f304e74fc2fb30fb45
Parents: d774005
Author: kurt <kurt@instaclustr.com>
Authored: Tue Dec 5 04:14:14 2017 +0000
Committer: Blake Eggleston <bdeggleston@gmail.com>
Committed: Thu Mar 8 15:34:13 2018 -0800

----------------------------------------------------------------------
 CHANGES.txt                                       |  1 +
 .../apache/cassandra/cql3/ColumnCondition.java    |  4 ++++
 .../operations/InsertUpdateIfConditionTest.java   | 18 ++++++++++++++++++
 3 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2c150980/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b49a349..9c6a853 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.17
+ * Fix NPE when performing comparison against a null frozen in LWT (CASSANDRA-14087)
  * Log when SSTables are deleted (CASSANDRA-14302)
  * Fix batch commitlog sync regression (CASSANDRA-14292)
  * Write to pending endpoint when view replica is also base replica (CASSANDRA-14251)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2c150980/src/java/org/apache/cassandra/cql3/ColumnCondition.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/ColumnCondition.java b/src/java/org/apache/cassandra/cql3/ColumnCondition.java
index 99e243c..c3a3af7 100644
--- a/src/java/org/apache/cassandra/cql3/ColumnCondition.java
+++ b/src/java/org/apache/cassandra/cql3/ColumnCondition.java
@@ -513,6 +513,10 @@ public class ColumnCondition
                 else
                     throw new InvalidRequestException(String.format("Invalid comparison with
null for operator \"%s\"", operator));
             }
+            else if (cell == null) // cell is null but condition has a value
+            {
+                return false;
+            }
 
             // make sure we use v3 serialization format for comparison
             ByteBuffer conditionValue;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2c150980/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
index 8adce7a..a47691a 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
@@ -871,6 +871,24 @@ public class InsertUpdateIfConditionTest extends CQLTester
         }
     }
 
+    @Test
+    public void testFrozenWithNullValues() throws Throwable
+    {
+        createTable(String.format("CREATE TABLE %%s (k int PRIMARY KEY, m %s)", "frozen<list<text>>"));
+        execute("INSERT INTO %s (k, m) VALUES (0, null)");
+
+        assertRows(execute("UPDATE %s SET m = ? WHERE k = 0 IF m = ?", list("test"), list("comparison")),
row(false, null));
+
+        createTable(String.format("CREATE TABLE %%s (k int PRIMARY KEY, m %s)", "frozen<map<text,int>>"));
+        execute("INSERT INTO %s (k, m) VALUES (0, null)");
+
+        assertRows(execute("UPDATE %s SET m = ? WHERE k = 0 IF m = ?", map("test", 3), map("comparison",
2)), row(false, null));
+
+        createTable(String.format("CREATE TABLE %%s (k int PRIMARY KEY, m %s)", "frozen<set<text>>"));
+        execute("INSERT INTO %s (k, m) VALUES (0, null)");
+
+        assertRows(execute("UPDATE %s SET m = ? WHERE k = 0 IF m = ?", set("test"), set("comparison")),
row(false, null));
+    }
     /**
      * Test expanded functionality from CASSANDRA-6839,
      * migrated from cql_tests.py:TestCQL.expanded_map_item_conditional_test()


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message