maedhroz commented on code in PR #1962:
URL: https://github.com/apache/cassandra/pull/1962#discussion_r1040125450


##########
test/unit/org/apache/cassandra/utils/Generators.java:
##########
@@ -60,6 +60,23 @@
     private static final Constraint DNS_DOMAIN_PART_CONSTRAINT = 
Constraint.between(0, DNS_DOMAIN_PART_DOMAIN.length - 1).withNoShrinkPoint();
 
     public static final Gen<String> IDENTIFIER_GEN = 
Generators.regexWord(SourceDSL.integers().between(1, 50));
+    public static final Gen<String> SYMBOL_GEN = 
filter(symbolGen(SourceDSL.integers().between(1, 48)), 
Generators::thisBugIsBroughtToYouByTheLetterP);
+    private static boolean thisBugIsBroughtToYouByTheLetterP(String value)
+    {
+        // In Lexer.g DURATION is before IDENT and Duration allows the 
following to parsse: P, and PT
+        // This causes an issue for cases that use IDENT as P and PT will not 
match as they matched DURATION already
+        // to avoid these cases, this function will be used to filter them out 
so only "valid" symbols are returned
+        // see CASSANDRA-17919
+        return !("P".equals(value) || "PT".equals(value));
+    }
+    private static final char CHAR_UNDERSCORE = 95;
+    public static Gen<String> symbolGen(Gen<Integer> size)
+    {
+        char[] domain = new char[LETTER_OR_DIGIT_DOMAIN.length + 1];
+        System.arraycopy(LETTER_OR_DIGIT_DOMAIN, 0, domain, 0, 
LETTER_OR_DIGIT_DOMAIN.length);
+        domain[domain.length - 1] = CHAR_UNDERSCORE;

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to