diff options
author | Léo Geoffroy <99647462+leo-geoffroy-sonarsource@users.noreply.github.com> | 2023-01-04 18:21:03 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-01-04 20:02:52 +0000 |
commit | 59bee1291aae239ee2c0edc353e2e527d2e42975 (patch) | |
tree | 456c123f13975cd990197d86cd37b836707e0120 /server/sonar-db-core/src | |
parent | ee69119351e6432bf221b2d74151ab99cf1c2546 (diff) | |
download | sonarqube-59bee1291aae239ee2c0edc353e2e527d2e42975.tar.gz sonarqube-59bee1291aae239ee2c0edc353e2e527d2e42975.zip |
SONAR-17737 Support null name for index lookup during index drop
Diffstat (limited to 'server/sonar-db-core/src')
-rw-r--r-- | server/sonar-db-core/src/main/java/org/sonar/db/DatabaseUtils.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/DatabaseUtils.java b/server/sonar-db-core/src/main/java/org/sonar/db/DatabaseUtils.java index c540743f96b..1a60105fe33 100644 --- a/server/sonar-db-core/src/main/java/org/sonar/db/DatabaseUtils.java +++ b/server/sonar-db-core/src/main/java/org/sonar/db/DatabaseUtils.java @@ -334,12 +334,13 @@ public class DatabaseUtils { */ public static Optional<String> findExistingIndex(Connection connection, String tableName, String indexName) { Predicate<String> indexSelector = idx -> indexName.equalsIgnoreCase(idx) || indexMatchesPattern(idx, format(INDEX_NAME_VARIATION, indexName)); + return findIndex(connection, tableName.toLowerCase(Locale.US), indexSelector) .or(() -> findIndex(connection, tableName.toUpperCase(Locale.US), indexSelector)); } - private static boolean indexMatchesPattern(String idx, String pattern) { - return Pattern.compile(pattern, Pattern.CASE_INSENSITIVE).matcher(idx).matches(); + private static boolean indexMatchesPattern(@Nullable String idx, String pattern) { + return idx != null && Pattern.compile(pattern, Pattern.CASE_INSENSITIVE).matcher(idx).matches(); } private static Optional<String> findIndex(Connection connection, String tableName, String indexName) { |