You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by db...@apache.org on 2012/05/31 02:37:54 UTC

[2/4] git commit: Oversize integer in CQL throws NumberFormatException (support for cql3) patch by dbrosius reviewed by pyaskevich for CASSANDRA-4291

Oversize integer in CQL throws NumberFormatException (support for cql3)
patch by dbrosius reviewed by pyaskevich for CASSANDRA-4291


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

Branch: refs/heads/trunk
Commit: 59f349de705f38daa8869c64817e27e9657ccc45
Parents: 6b4e5f7
Author: Dave Brosius <db...@apache.org>
Authored: Wed May 30 20:30:36 2012 -0400
Committer: Dave Brosius <db...@apache.org>
Committed: Wed May 30 20:30:36 2012 -0400

----------------------------------------------------------------------
 .../org/apache/cassandra/cql3/QueryProcessor.java  |   40 +++++++++------
 1 files changed, 24 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/59f349de/src/java/org/apache/cassandra/cql3/QueryProcessor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/QueryProcessor.java b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
index b58d943..4f08bac 100644
--- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
@@ -22,7 +22,6 @@ import java.nio.ByteBuffer;
 import java.util.*;
 
 import org.antlr.runtime.*;
-import org.apache.cassandra.db.marshal.UTF8Type;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -218,21 +217,30 @@ public class QueryProcessor
 
     private static ParsedStatement parseStatement(String queryStr) throws InvalidRequestException, RecognitionException
     {
-        // Lexer and parser
-        CharStream stream = new ANTLRStringStream(queryStr);
-        CqlLexer lexer = new CqlLexer(stream);
-        TokenStream tokenStream = new CommonTokenStream(lexer);
-        CqlParser parser = new CqlParser(tokenStream);
-
-        // Parse the query string to a statement instance
-        ParsedStatement statement = parser.query();
-
-        // The lexer and parser queue up any errors they may have encountered
-        // along the way, if necessary, we turn them into exceptions here.
-        lexer.throwLastRecognitionError();
-        parser.throwLastRecognitionError();
-
-        return statement;
+        try
+        {
+            // Lexer and parser
+            CharStream stream = new ANTLRStringStream(queryStr);
+            CqlLexer lexer = new CqlLexer(stream);
+            TokenStream tokenStream = new CommonTokenStream(lexer);
+            CqlParser parser = new CqlParser(tokenStream);
+    
+            // Parse the query string to a statement instance
+            ParsedStatement statement = parser.query();
+    
+            // The lexer and parser queue up any errors they may have encountered
+            // along the way, if necessary, we turn them into exceptions here.
+            lexer.throwLastRecognitionError();
+            parser.throwLastRecognitionError();
+    
+            return statement;
+        }
+        catch (RuntimeException re)
+        {
+            InvalidRequestException ire = new InvalidRequestException("Failed parsing statement: [" + queryStr + "] reason: " + re.getClass().getSimpleName() + " " + re.getMessage());
+            ire.initCause(re);
+            throw ire;
+        }
     }
 
 }