cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject [1/2] git commit: Avoid NPE on null nested UDT inside a set
Date Wed, 15 Oct 2014 18:49:20 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 2623982e8 -> e1c5ebde3


Avoid NPE on null nested UDT inside a set

Patch by Robert Stupp; reviewed by Tyler Hobbs for CASSANDRA-8105


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

Branch: refs/heads/trunk
Commit: f6ea46e93ccd9d5388a6f0fa37ddef9cf2279997
Parents: ba79107
Author: Robert Stupp <snazy@snazy.de>
Authored: Wed Oct 15 13:48:14 2014 -0500
Committer: Tyler Hobbs <tylerhobbs@apache.org>
Committed: Wed Oct 15 13:48:14 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                      |  1 +
 .../apache/cassandra/db/marshal/TupleType.java   |  5 +----
 .../org/apache/cassandra/cql3/UserTypesTest.java | 19 +++++++++++++++++++
 3 files changed, 21 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f6ea46e9/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 4da1e56..0d39416 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.1
+ * Fix NPE on null nested UDT inside a set (CASSANDRA-8105)
  * Fix exception when querying secondary index on set items or map keys
    when some clustering columns are specified (CASSANDRA-8073)
  * Send proper error response when there is an error during native

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f6ea46e9/src/java/org/apache/cassandra/db/marshal/TupleType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/TupleType.java b/src/java/org/apache/cassandra/db/marshal/TupleType.java
index a7a83ea..42aaba1 100644
--- a/src/java/org/apache/cassandra/db/marshal/TupleType.java
+++ b/src/java/org/apache/cassandra/db/marshal/TupleType.java
@@ -72,8 +72,7 @@ public class TupleType extends AbstractType<ByteBuffer>
         ByteBuffer bb1 = o1.duplicate();
         ByteBuffer bb2 = o2.duplicate();
 
-        int i = 0;
-        while (bb1.remaining() > 0 && bb2.remaining() > 0)
+        for (int i = 0; bb1.remaining() > 0 && bb2.remaining() > 0; i++)
         {
             AbstractType<?> comparator = types.get(i);
 
@@ -95,8 +94,6 @@ public class TupleType extends AbstractType<ByteBuffer>
             int cmp = comparator.compare(value1, value2);
             if (cmp != 0)
                 return cmp;
-
-            ++i;
         }
 
         if (bb1.remaining() == 0)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f6ea46e9/test/unit/org/apache/cassandra/cql3/UserTypesTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/UserTypesTest.java b/test/unit/org/apache/cassandra/cql3/UserTypesTest.java
index ca84102..184de19 100644
--- a/test/unit/org/apache/cassandra/cql3/UserTypesTest.java
+++ b/test/unit/org/apache/cassandra/cql3/UserTypesTest.java
@@ -32,6 +32,25 @@ public class UserTypesTest extends CQLTester
     }
 
     @Test
+    public void testCassandra8105() throws Throwable
+    {
+        String ut1 = createType("CREATE TYPE %s (a int, b int)");
+        String ut2 = createType("CREATE TYPE %s (j frozen<" + KEYSPACE + "." + ut1 + ">,
k int)");
+        createTable("CREATE TABLE %s (x int PRIMARY KEY, y set<frozen<" + KEYSPACE
+ "." + ut2 + ">>)");
+        execute("INSERT INTO %s (x, y) VALUES (1, { { k: 1 } })");
+
+        String ut3 = createType("CREATE TYPE %s (a int, b int)");
+        String ut4 = createType("CREATE TYPE %s (j frozen<" + KEYSPACE + "." + ut3 + ">,
k int)");
+        createTable("CREATE TABLE %s (x int PRIMARY KEY, y list<frozen<" + KEYSPACE
+ "." + ut4 + ">>)");
+        execute("INSERT INTO %s (x, y) VALUES (1, [ { k: 1 } ])");
+
+        String ut5 = createType("CREATE TYPE %s (a int, b int)");
+        String ut6 = createType("CREATE TYPE %s (i int, j frozen<" + KEYSPACE + "." +
ut5 + ">)");
+        createTable("CREATE TABLE %s (x int PRIMARY KEY, y set<frozen<" + KEYSPACE
+ "." + ut6 + ">>)");
+        execute("INSERT INTO %s (x, y) VALUES (1, { { i: 1 } })");
+    }
+
+    @Test
     public void testFor7684() throws Throwable
     {
         String myType = createType("CREATE TYPE %s (x double)");


Mime
View raw message