aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-core/src
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2018-10-31 09:45:07 +0100
committersonartech <sonartech@sonarsource.com>2018-11-01 09:32:48 +0100
commit35229142c6eaf780a70fcf838280cc7aee4fe515 (patch)
treea07a89b85d35b9a6ea444a7abef68ff6f749c141 /server/sonar-db-core/src
parenta48e4614140ac17c5d93f0ac65074916c5f323c9 (diff)
downloadsonarqube-35229142c6eaf780a70fcf838280cc7aee4fe515.tar.gz
sonarqube-35229142c6eaf780a70fcf838280cc7aee4fe515.zip
fix DialectUtils: Dialects should not be statically stored
Diffstat (limited to 'server/sonar-db-core/src')
-rw-r--r--server/sonar-db-core/src/main/java/org/sonar/db/dialect/DialectUtils.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/dialect/DialectUtils.java b/server/sonar-db-core/src/main/java/org/sonar/db/dialect/DialectUtils.java
index 8ecd7cb83cd..05cc5652205 100644
--- a/server/sonar-db-core/src/main/java/org/sonar/db/dialect/DialectUtils.java
+++ b/server/sonar-db-core/src/main/java/org/sonar/db/dialect/DialectUtils.java
@@ -19,15 +19,17 @@
*/
package org.sonar.db.dialect;
-import java.util.Arrays;
+import com.google.common.collect.ImmutableSet;
import java.util.Optional;
+import java.util.Set;
import java.util.function.Predicate;
+import java.util.function.Supplier;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.utils.MessageException;
public final class DialectUtils {
- private static final Dialect[] DIALECTS = new Dialect[] {new H2(), new MySql(), new Oracle(), new PostgreSql(), new MsSql()};
+ private static final Set<Supplier<Dialect>> DIALECTS = ImmutableSet.of(H2::new, MySql::new, Oracle::new, PostgreSql::new, MsSql::new);
private DialectUtils() {
// only static stuff
@@ -48,7 +50,8 @@ public final class DialectUtils {
}
private static Optional<Dialect> findDialect(Predicate<Dialect> predicate) {
- return Arrays.stream(DIALECTS)
+ return DIALECTS.stream()
+ .map(Supplier::get)
.filter(predicate)
.findFirst();
}