Oversize integer in CQL throws NumberFormatException 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/edfc06fd Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/edfc06fd Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/edfc06fd Branch: refs/heads/cassandra-1.1 Commit: edfc06fdd0794831cf7d1401fa98ff38bb4e4210 Parents: 043d180 Author: Dave Brosius <[email protected]> Authored: Wed May 30 20:17:13 2012 -0400 Committer: Dave Brosius <[email protected]> Committed: Wed May 30 20:17:13 2012 -0400 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../org/apache/cassandra/cql/QueryProcessor.java | 39 +++++++++------ 2 files changed, 25 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/edfc06fd/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index b566c6f..4fd2155 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,6 +5,7 @@ (CASSANDRA-4279) * improve ability of STCS.getBuckets to deal with 100s of 1000s of sstables, such as when convertinb back from LCS (CASSANDRA-4287) + * Oversize integer in CQL throws NumberFormatException (CASSANDRA-4291) 1.0.10 http://git-wip-us.apache.org/repos/asf/cassandra/blob/edfc06fd/src/java/org/apache/cassandra/cql/QueryProcessor.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql/QueryProcessor.java b/src/java/org/apache/cassandra/cql/QueryProcessor.java index 9900f47..53c4e86 100644 --- a/src/java/org/apache/cassandra/cql/QueryProcessor.java +++ b/src/java/org/apache/cassandra/cql/QueryProcessor.java @@ -1021,21 +1021,30 @@ public class QueryProcessor private static CQLStatement getStatement(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 - CQLStatement 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 + CQLStatement 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; + } } private static void validateSchemaIsSettled() throws SchemaDisagreementException
