-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validate the regex pattern of database-name and table-name in table f… #526
Conversation
Map<String, String> properties = getAllOptions(); | ||
properties.put("table-name", "*_invalid_table"); | ||
} catch (Throwable t) { | ||
String msg = String.format("The table-name is invalid: '%s'", "*_invalid_table"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need String.format
here because the string is deterministic.
@@ -231,4 +234,22 @@ private void validateFetchSize(int fetchSize) { | |||
"The value of option '%s' must larger than 1, but is %d", | |||
SCAN_SNAPSHOT_FETCH_SIZE.key(), fetchSize)); | |||
} | |||
|
|||
private void validateDatabaseName(String databaseName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validateDatabaseName
and validateTableName
can share a same method, e.g.
/**
* Checks the given regular expression's syntax is valid.
*
* @param optionName the option name of the regex
* @param regex The regular expression to be checked
* @throws ValidationException If the expression's syntax is invalid
*/
private void validateRegex(String optionName, String regex) {
try {
Pattern.compile(regex);
} catch (Exception e) {
throw new ValidationException(
String.format(
"The %s '%s' is not a valid regular expression", optionName, regex),
e);
}
}
b4afba3
to
a822c05
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…actory #491
Add validation check for the regex pattern of database-name and table-name in table factory to avoid exception during runtime