cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [2/3] git commit: Copy ResultSet on count query to avoid ConcurrentModificationException
Date Wed, 27 Mar 2013 10:42:35 GMT
Copy ResultSet on count query to avoid ConcurrentModificationException

patch by slebresne; reviewed by jbellis for CASSANDRA-5282


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

Branch: refs/heads/trunk
Commit: 61e329f7aea6a502c274277ca448c6207072a376
Parents: 193e566
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Wed Mar 27 11:41:36 2013 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Wed Mar 27 11:41:36 2013 +0100

----------------------------------------------------------------------
 CHANGES.txt                                       |    1 +
 src/java/org/apache/cassandra/cql3/ResultSet.java |   11 +++++------
 2 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/61e329f7/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 7eaefaa..26b2360 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -11,6 +11,7 @@
  * Optimize min/max timestamp collection (CASSANDRA-5373)
  * Invalid streamId in cql binary protocol when using invalid CL (CASSANDRA-5164)
  * Fix validation for IN where clauses with collections (CASSANDRA-5376)
+ * Copy resultSet on count query to avoid ConcurrentModificationException (CASSANDRA-5382)
 Merged from 1.1:
  * cli: Quote ks and cf names in schema output when needed (CASSANDRA-5052)
  * Fix bad default for min/max timestamp in SSTableMetadata (CASSANDRA-5372)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/61e329f7/src/java/org/apache/cassandra/cql3/ResultSet.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/ResultSet.java b/src/java/org/apache/cassandra/cql3/ResultSet.java
index 290653f..3ddfdc4 100644
--- a/src/java/org/apache/cassandra/cql3/ResultSet.java
+++ b/src/java/org/apache/cassandra/cql3/ResultSet.java
@@ -96,13 +96,12 @@ public class ResultSet
     {
         String ksName = metadata.names.get(0).ksName;
         String cfName = metadata.names.get(0).cfName;
-        metadata.names.clear();
-        metadata.names.add(new ColumnSpecification(ksName, cfName, COUNT_COLUMN, LongType.instance));
-
         long count = rows.size();
-        rows.clear();
-        rows.add(Collections.singletonList(ByteBufferUtil.bytes(count)));
-        return this;
+
+        Metadata newMetadata = new Metadata(Collections.singletonList(new ColumnSpecification(ksName,
cfName, COUNT_COLUMN, LongType.instance)));
+        List<List<ByteBuffer>> newRows = Collections.singletonList(Collections.singletonList(ByteBufferUtil.bytes(count)));
+
+        return new ResultSet(newMetadata, newRows);
     }
 
     public CqlResult toThriftResult()


Mime
View raw message