Merge branch 'cassandra-2.0' into cassandra-2.1
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b969496e Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b969496e Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b969496e Branch: refs/heads/trunk Commit: b969496e47be72d6f094f7c7db4ebac97104f924 Parents: efebd8f c939422 Author: Benjamin Lerer <[email protected][email protected]> Authored: Mon Jun 22 16:42:43 2015 +0200 Committer: Robert Stupp <[email protected]> Committed: Mon Jun 22 16:42:43 2015 +0200 ---------------------------------------------------------------------- CHANGES.txt | 1 + src/java/org/apache/cassandra/cql3/Cql.g | 4 +-- .../cql3/CreateAndAlterKeyspaceTest.java | 37 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/b969496e/CHANGES.txt ---------------------------------------------------------------------- diff --cc CHANGES.txt index 9ae0969,6e3a147..28b145b --- a/CHANGES.txt +++ b/CHANGES.txt @@@ -1,7 -1,9 +1,8 @@@ -2.0.17 +2.1.7 + * Fix bug in cardinality check when compacting (CASSANDRA-9580) + * Fix memory leak in Ref due to ConcurrentLinkedQueue.remove() behaviour (CASSANDRA-9549) +Merged from 2.0 + * 'WITH WITH' in alter keyspace statements causes NPE (CASSANDRA-9565) - * Display min timestamp in sstablemetadata viewer (CASSANDRA-6767) - - -2.0.16: * Expose some internals of SelectStatement for inspection (CASSANDRA-9532) * ArrivalWindow should use primitives (CASSANDRA-9496) * Periodically submit background compaction tasks (CASSANDRA-9592) http://git-wip-us.apache.org/repos/asf/cassandra/blob/b969496e/src/java/org/apache/cassandra/cql3/Cql.g ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/cql3/Cql.g index f9a07b3,8b382fa..db8ef25 --- a/src/java/org/apache/cassandra/cql3/Cql.g +++ b/src/java/org/apache/cassandra/cql3/Cql.g @@@ -1030,8 -891,8 +1030,8 @@@ properties[PropertyDefinitions props ; property[PropertyDefinitions props] - : k=ident '=' (simple=propertyValue { try { $props.addProperty(k.toString(), simple); } catch (SyntaxException e) { addRecognitionError(e.getMessage()); } } - | map=mapLiteral { try { $props.addProperty(k.toString(), convertPropertyMap(map)); } catch (SyntaxException e) { addRecognitionError(e.getMessage()); } }) + : k=ident '=' simple=propertyValue { try { $props.addProperty(k.toString(), simple); } catch (SyntaxException e) { addRecognitionError(e.getMessage()); } } - | k=ident '=' map=map_literal { try { $props.addProperty(k.toString(), convertPropertyMap(map)); } catch (SyntaxException e) { addRecognitionError(e.getMessage()); } } ++ | k=ident '=' map=mapLiteral { try { $props.addProperty(k.toString(), convertPropertyMap(map)); } catch (SyntaxException e) { addRecognitionError(e.getMessage()); } } ; propertyValue returns [String str] http://git-wip-us.apache.org/repos/asf/cassandra/blob/b969496e/test/unit/org/apache/cassandra/cql3/CreateAndAlterKeyspaceTest.java ---------------------------------------------------------------------- diff --cc test/unit/org/apache/cassandra/cql3/CreateAndAlterKeyspaceTest.java index 0000000,45be0df..9e0ca21 mode 000000,100644..100644 --- a/test/unit/org/apache/cassandra/cql3/CreateAndAlterKeyspaceTest.java +++ b/test/unit/org/apache/cassandra/cql3/CreateAndAlterKeyspaceTest.java @@@ -1,0 -1,89 +1,37 @@@ + /* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apache.cassandra.cql3; + -import org.junit.AfterClass; -import org.junit.BeforeClass; + import org.junit.Test; + -import org.apache.cassandra.SchemaLoader; -import org.apache.cassandra.db.ConsistencyLevel; -import org.apache.cassandra.exceptions.SyntaxException; -import org.apache.cassandra.gms.Gossiper; - -import static org.apache.cassandra.cql3.QueryProcessor.process; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -public class CreateAndAlterKeyspaceTest ++public class CreateAndAlterKeyspaceTest extends CQLTester + { - @BeforeClass - public static void setUpClass() throws Throwable - { - SchemaLoader.loadSchema(); - } - - @AfterClass - public static void stopGossiper() - { - Gossiper.instance.stop(); - } - + @Test + // tests CASSANDRA-9565 + public void testCreateAndAlterWithDoubleWith() throws Throwable + { + String[] stmts = new String[] {"ALTER KEYSPACE WITH WITH DURABLE_WRITES = true", + "ALTER KEYSPACE ks WITH WITH DURABLE_WRITES = true", + "CREATE KEYSPACE WITH WITH DURABLE_WRITES = true", + "CREATE KEYSPACE ks WITH WITH DURABLE_WRITES = true"}; + + for (String stmt : stmts) { - assertInvalidSyntax(stmt, "no viable alternative at input 'WITH'"); - } - } - - /** - * Checks that the specified statement result in a <code>SyntaxException</code> containing the specified message. - * - * @param stmt the statement to check - */ - private static void assertInvalidSyntax(String stmt, String msg) throws Throwable { - try { - process(stmt, ConsistencyLevel.ONE); - fail(); - } catch (RuntimeException e) { - assertSyntaxException(e.getCause(), msg); ++ assertInvalidSyntaxMessage("no viable alternative at input 'WITH'", stmt); + } + } - - /** - * Asserts that the specified exception is a <code>SyntaxException</code> for which the error message contains - * the specified text. - * - * @param exception the exception to test - * @param expectedContent the expected content of the error message - */ - private static void assertSyntaxException(Throwable exception, String expectedContent) { - assertTrue("The exception should be a SyntaxException but is not", exception instanceof SyntaxException); - - String msg = exception.getMessage(); - assertTrue(String.format("The error message was expected to contains: %s but was %s", expectedContent, msg), - msg.contains(expectedContent)); - } + }
