datastrato / gravitino

World's most powerful data catalog service with providing a high-performance, geo-distributed and federated metadata lake.
https://datastrato.ai/docs/
Apache License 2.0
328 stars 146 forks source link

[Improvement] Improve greedy regular expressions #3088

Open justinmclean opened 1 week ago

justinmclean commented 1 week ago

What would you like to be improved?

In DorisExceptionConverter.java we have a greedy regular expression that could potentially cause issues.

  private static final String DATABASE_ALREADY_EXISTS_PATTERN_STRING =
      ".*detailMessage = Can't create database '.*'; database exists";

How should we improve?

Change the regular expression to not be greedy or don't use a regular expression.

BSSsunny commented 1 week ago

How about change it to private static final String DATABASE_ALREADY_EXISTS_PATTERN_STRING = ".*?detailMessage = Can't create database '.*?'; database exists";