You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2013/01/09 12:06:23 UTC

git commit: Fix unfriendly error message (CASSANDRA-5132)

Updated Branches:
  refs/heads/cassandra-1.2 b9ded6456 -> cc0c9f35b


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/cassandra-1.2
Commit: cc0c9f35b18193ef947fdc84a943ee29408b18b4
Parents: b9ded64
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Wed Jan 9 12:06:14 2013 +0100
Committer: Sylvain Lebresne <sy...@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