Return-Path: Delivered-To: apmail-incubator-cassandra-commits-archive@minotaur.apache.org Received: (qmail 40261 invoked from network); 13 Oct 2009 15:48:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 Oct 2009 15:48:09 -0000 Received: (qmail 14210 invoked by uid 500); 13 Oct 2009 15:48:09 -0000 Delivered-To: apmail-incubator-cassandra-commits-archive@incubator.apache.org Received: (qmail 13870 invoked by uid 500); 13 Oct 2009 15:48:08 -0000 Mailing-List: contact cassandra-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cassandra-dev@incubator.apache.org Delivered-To: mailing list cassandra-commits@incubator.apache.org Received: (qmail 13717 invoked by uid 99); 13 Oct 2009 15:48:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Oct 2009 15:48:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Oct 2009 15:48:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 99A1223888BD; Tue, 13 Oct 2009 15:47:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r824815 - in /incubator/cassandra/branches/cassandra-0.4: src/java/org/apache/cassandra/service/CassandraServer.java test/system/test_server.py Date: Tue, 13 Oct 2009 15:47:43 -0000 To: cassandra-commits@incubator.apache.org From: jbellis@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091013154743.99A1223888BD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jbellis Date: Tue Oct 13 15:47:43 2009 New Revision: 824815 URL: http://svn.apache.org/viewvc?rev=824815&view=rev Log: Add missing validateKey calls for inserts, and move get key validation where it's more visible. Also remove inconsistent trim-ing of keys. patch by jbellis; tested by Eric Lubow for CASSANDRA-486 Modified: incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/CassandraServer.java incubator/cassandra/branches/cassandra-0.4/test/system/test_server.py Modified: incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/CassandraServer.java URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/CassandraServer.java?rev=824815&r1=824814&r2=824815&view=diff ============================================================================== --- incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/CassandraServer.java (original) +++ incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/CassandraServer.java Tue Oct 13 15:47:43 2009 @@ -80,11 +80,6 @@ Map columnFamilyKeyMap = new HashMap(); - for (ReadCommand command: commands) - { - ThriftValidation.validateKey(command.key); - } - if (consistency_level == ConsistencyLevel.ZERO) { throw new InvalidRequestException("Consistency level zero may not be applied to read operations"); @@ -238,13 +233,19 @@ if (predicate.column_names != null) { for (String key: keys) + { + ThriftValidation.validateKey(key); commands.add(new SliceByNamesReadCommand(keyspace, key, column_parent, predicate.column_names)); + } ThriftValidation.validateColumns(keyspace, column_parent, predicate.column_names); } else { for (String key: keys) + { + ThriftValidation.validateKey(key); commands.add(new SliceFromReadCommand(keyspace, key, column_parent, range.start, range.finish, range.reversed, range.count)); + } ThriftValidation.validateRange(keyspace, column_parent, range); } @@ -318,6 +319,7 @@ List commands = new ArrayList(); for (String key: keys) { + ThriftValidation.validateKey(key); commands.add(new SliceByNamesReadCommand(table, key, path, nameAsList)); } @@ -380,6 +382,7 @@ List commands = new ArrayList(); for (String key: keys) { + ThriftValidation.validateKey(key); commands.add(new SliceFromReadCommand(table, key, column_parent, ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, true, Integer.MAX_VALUE)); } @@ -409,7 +412,7 @@ ThriftValidation.validateKey(key); ThriftValidation.validateColumnPath(table, column_path); - RowMutation rm = new RowMutation(table, key.trim()); + RowMutation rm = new RowMutation(table, key); try { rm.add(new QueryPath(column_path), value, timestamp); @@ -426,6 +429,7 @@ { if (logger.isDebugEnabled()) logger.debug("batch_insert"); + ThriftValidation.validateKey(key); for (String cfName : cfmap.keySet()) { @@ -453,9 +457,10 @@ { if (logger.isDebugEnabled()) logger.debug("remove"); + ThriftValidation.validateKey(key); ThriftValidation.validateColumnPathOrParent(table, column_path); - RowMutation rm = new RowMutation(table, key.trim()); + RowMutation rm = new RowMutation(table, key); rm.delete(new QueryPath(column_path), timestamp); doInsert(consistency_level, rm); Modified: incubator/cassandra/branches/cassandra-0.4/test/system/test_server.py URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/test/system/test_server.py?rev=824815&r1=824814&r2=824815&view=diff ============================================================================== --- incubator/cassandra/branches/cassandra-0.4/test/system/test_server.py (original) +++ incubator/cassandra/branches/cassandra-0.4/test/system/test_server.py Tue Oct 13 15:47:43 2009 @@ -289,6 +289,11 @@ def test_bad_calls(self): # supercolumn in a non-super CF _expect_exception(lambda: client.insert('Keyspace1', 'key1', ColumnPath('Standard1', 'x', 'y'), 'value', 0, ConsistencyLevel.ONE), InvalidRequestException) + # empty key + _expect_exception(lambda: client.get('Keyspace1', '', ColumnPath('Standard1', column='c1'), ConsistencyLevel.ONE), InvalidRequestException) + cfmap = {'Super1': [ColumnOrSuperColumn(super_column=c) for c in _SUPER_COLUMNS], + 'Super2': [ColumnOrSuperColumn(super_column=c) for c in _SUPER_COLUMNS]} + _expect_exception(lambda: client.batch_insert('Keyspace1', '', cfmap, ConsistencyLevel.ONE), InvalidRequestException) # get doesn't specify column name _expect_exception(lambda: client.get('Keyspace1', 'key1', ColumnPath('Standard1'), ConsistencyLevel.ONE), InvalidRequestException) # supercolumn in a non-super CF