diff --git a/CHANGES.txt b/CHANGES.txt index b566c6f3b6..4fd2155fd4 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 diff --git a/src/java/org/apache/cassandra/cql/QueryProcessor.java b/src/java/org/apache/cassandra/cql/QueryProcessor.java index 9900f47aaa..53c4e862d4 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