cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [3/6] cassandra git commit: Avoid possible stack overflow in ModificationStatement::getFunctions
Date Thu, 21 Apr 2016 17:46:33 GMT
Avoid possible stack overflow in ModificationStatement::getFunctions

Patch by Alex Petrov; reviewed by Sam Tunnicliffe for CASSANDRA-11621


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

Branch: refs/heads/trunk
Commit: 3244774572c56400ed96da4d57912779878c16e5
Parents: b80ff54
Author: Alex Petrov <oleksandr.petrov@gmail.com>
Authored: Thu Apr 21 11:46:09 2016 +0200
Committer: Sam Tunnicliffe <sam@beobal.com>
Committed: Thu Apr 21 18:41:43 2016 +0100

----------------------------------------------------------------------
 CHANGES.txt                                            |  1 +
 .../cql3/statements/ModificationStatement.java         | 13 ++++++-------
 2 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/32447745/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index e51e6d2..d16f6f6 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.2.7
+ * Avoid calling Iterables::concat in loops during ModificationStatement::getFunctions (CASSANDRA-11621)
  * cqlsh: COPY FROM should use regular inserts for single statement batches and
           report errors correctly if workers processes crash on initialization (CASSANDRA-11474)
  * Always close cluster with connection in CqlRecordWriter (CASSANDRA-11553)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/32447745/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
index fbdfc0c..059d113 100644
--- a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
@@ -99,24 +99,23 @@ public abstract class ModificationStatement implements CQLStatement
 
     public Iterable<Function> getFunctions()
     {
-        Iterable<Function> functions = attrs.getFunctions();
-
+        List<Iterable<Function>> iterables = new LinkedList<>();
         for (Restriction restriction : processedKeys.values())
-                functions = Iterables.concat(functions, restriction.getFunctions());
+            iterables.add(restriction.getFunctions());
 
         if (columnOperations != null)
             for (Operation operation : columnOperations)
-                functions = Iterables.concat(functions, operation.getFunctions());
+                iterables.add(operation.getFunctions());
 
         if (columnConditions != null)
             for (ColumnCondition condition : columnConditions)
-                functions = Iterables.concat(functions, condition.getFunctions());
+                iterables.add(condition.getFunctions());
 
         if (staticConditions != null)
             for (ColumnCondition condition : staticConditions)
-                functions = Iterables.concat(functions, condition.getFunctions());
+                iterables.add(condition.getFunctions());
 
-        return functions;
+        return Iterables.concat(iterables);
     }
 
     public abstract boolean requireFullClusteringKey();


Mime
View raw message