Fix unfriendly error message (CASSANDRA-5132)
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/cc0c9f35 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/cc0c9f35 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/cc0c9f35 Branch: refs/heads/trunk Commit: cc0c9f35b18193ef947fdc84a943ee29408b18b4 Parents: b9ded64 Author: Sylvain Lebresne <sylv...@datastax.com> Authored: Wed Jan 9 12:06:14 2013 +0100 Committer: Sylvain Lebresne <sylv...@datastax.com> Committed: Wed Jan 9 12:06:14 2013 +0100 ---------------------------------------------------------------------- src/java/org/apache/cassandra/cql3/Cql.g | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/cc0c9f35/src/java/org/apache/cassandra/cql3/Cql.g ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql3/Cql.g b/src/java/org/apache/cassandra/cql3/Cql.g index d9bd3e5..146b09f 100644 --- a/src/java/org/apache/cassandra/cql3/Cql.g +++ b/src/java/org/apache/cassandra/cql3/Cql.g @@ -783,7 +783,7 @@ comparatorType returns [ParsedType t] } catch (SyntaxException e) { addRecognitionError("Cannot parse type " + $s.text + ": " + e.getMessage()); } catch (ConfigurationException e) { - addRecognitionError("Errot setting type " + $s.text + ": " + e.getMessage()); + addRecognitionError("Error setting type " + $s.text + ": " + e.getMessage()); } } ; @@ -809,11 +809,15 @@ native_type returns [ParsedType t] collection_type returns [ParsedType pt] : K_MAP '<' t1=comparatorType ',' t2=comparatorType '>' - { try { $pt = ParsedType.Collection.map(t1, t2); } catch (InvalidRequestException e) { addRecognitionError(e.getMessage()); } } + { try { + // if we can't parse either t1 or t2, antlr will "recover" and we may have t1 or t2 null. + if (t1 != null && t2 != null) + $pt = ParsedType.Collection.map(t1, t2); + } catch (InvalidRequestException e) { addRecognitionError(e.getMessage()); } } | K_LIST '<' t=comparatorType '>' - { try { $pt = ParsedType.Collection.list(t); } catch (InvalidRequestException e) { addRecognitionError(e.getMessage()); } } + { try { if (t != null) $pt = ParsedType.Collection.list(t); } catch (InvalidRequestException e) { addRecognitionError(e.getMessage()); } } | K_SET '<' t=comparatorType '>' - { try { $pt = ParsedType.Collection.set(t); } catch (InvalidRequestException e) { addRecognitionError(e.getMessage()); } } + { try { if (t != null) $pt = ParsedType.Collection.set(t); } catch (InvalidRequestException e) { addRecognitionError(e.getMessage()); } } ; username