Skip to content

Commit

Permalink
Capture and ignore exceptions in the CQLParser getOperationAndTableNa…
Browse files Browse the repository at this point in the history
…me method used by Cassandra 4.x to address #827
  • Loading branch information
GDownes committed May 18, 2022
1 parent 103d81c commit 58897bf
Showing 1 changed file with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,25 @@ public class CQLParser {
}

public OperationAndTableName getOperationAndTableName(String rawQuery) {
rawQuery = rawQuery.replaceAll(COMMENT_PATTERN, "").trim();
try {
rawQuery = rawQuery.replaceAll(COMMENT_PATTERN, "").trim();

String operation = null;
String tableName = null;
for (Pattern pattern : PATTERNS) {
Matcher matcher = pattern.matcher(rawQuery);
if (matcher.find()) {
if (matcher.groupCount() >= 1) {
operation = matcher.group(1);
String operation = null;
String tableName = null;
for (Pattern pattern : PATTERNS) {
Matcher matcher = pattern.matcher(rawQuery);
if (matcher.find()) {
if (matcher.groupCount() >= 1) {
operation = matcher.group(1);
}
if (matcher.groupCount() == 2) {
tableName = matcher.group(2);
}
return new OperationAndTableName(operation, tableName);
}
if (matcher.groupCount() == 2) {
tableName = matcher.group(2);
}
return new OperationAndTableName(operation, tableName);
}
} catch (Exception ex) {
return null;
}
return null;
}
Expand Down

0 comments on commit 58897bf

Please sign in to comment.