]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-17200 Ignore unused sonar.jdbc.* properties for HikariCP
authorJacek <jacek.poreda@sonarsource.com>
Tue, 30 Aug 2022 07:23:41 +0000 (09:23 +0200)
committersonartech <sonartech@sonarsource.com>
Tue, 30 Aug 2022 20:03:14 +0000 (20:03 +0000)
server/sonar-db-core/src/main/java/org/sonar/db/DefaultDatabase.java
sonar-application/src/main/assembly/conf/sonar.properties

index 837b941f445a4f074953a67a0558a26af41ba344..0b1bd78451c3dee86946a55b9b25ead5227fd228 100644 (file)
@@ -43,7 +43,6 @@ import org.sonar.process.logging.LogbackHelper;
 
 import static com.google.common.base.Preconditions.checkState;
 import static java.lang.String.format;
-import static org.sonar.process.ProcessProperties.Property.JDBC_DRIVER_PATH;
 import static org.sonar.process.ProcessProperties.Property.JDBC_EMBEDDED_PORT;
 import static org.sonar.process.ProcessProperties.Property.JDBC_MIN_IDLE;
 import static org.sonar.process.ProcessProperties.Property.JDBC_PASSWORD;
@@ -68,10 +67,23 @@ public class DefaultDatabase implements Database {
     "sonar.jdbc.minEvictableIdleTimeMillis",
     "sonar.jdbc.timeBetweenEvictionRunsMillis");
 
-  private static final Set<String> IGNORED_SONAR_PROPERTIES = Set.of(SONAR_JDBC_DIALECT, JDBC_DRIVER_PATH.getKey(),
-    "sonar.jdbc.maxIdle",
-    "sonar.jdbc.minEvictableIdleTimeMillis",
-    "sonar.jdbc.timeBetweenEvictionRunsMillis");
+  private static final Set<String> ALLOWED_SONAR_PROPERTIES = Set.of(
+    JDBC_USERNAME.getKey(),
+    JDBC_PASSWORD.getKey(),
+    JDBC_EMBEDDED_PORT.getKey(),
+    JDBC_URL.getKey(),
+    JDBC_MIN_IDLE.getKey(),
+    SONAR_JDBC_MAX_WAIT,
+    SONAR_JDBC_MAX_ACTIVE,
+    // allowed hikari cp direct properties
+    SONAR_JDBC_DRIVER,
+    "sonar.jdbc.dataSource.user",
+    "sonar.jdbc.dataSource.password",
+    "sonar.jdbc.dataSource.portNumber",
+    "sonar.jdbc.jdbcUrl",
+    "sonar.jdbc.connectionTimeout",
+    "sonar.jdbc.maximumPoolSize",
+    "sonar.jdbc.minimumIdle");
 
   private static final Map<String, String> SONAR_JDBC_TO_HIKARI_PROPERTY_MAPPINGS = Map.of(
     JDBC_USERNAME.getKey(), "dataSource.user",
@@ -195,7 +207,7 @@ public class DefaultDatabase implements Database {
     Properties result = new Properties();
     for (Map.Entry<Object, Object> entry : properties.entrySet()) {
       String key = (String) entry.getKey();
-      if (IGNORED_SONAR_PROPERTIES.contains(key)) {
+      if (!ALLOWED_SONAR_PROPERTIES.contains(key)) {
         if (DEPRECATED_SONAR_PROPERTIES.contains(key)) {
           LOG.warn("Property [{}] has no effect as pool connection implementation changed, check 9.7 upgrade notes.", key);
         }
index d24fd2dc23ac4a838ffc93d983a65baff16af8e5..fc3c22b91efadb81bf057409376cf8ece2ccda86 100644 (file)
 # then sonar.jdbc.maxActive should be 1.2 * 50 = 60.
 #sonar.jdbc.maxActive=60
 
-# The maximum number of connections that can remain idle in the
-# pool, without extra ones being released, or negative for no limit.
-#sonar.jdbc.maxIdle=5
-
 # The minimum number of connections that can remain idle in the pool,
 # without extra ones being created, or zero to create none.
 #sonar.jdbc.minIdle=10
@@ -72,7 +68,6 @@
 #sonar.jdbc.maxWait=8000
 
 
-
 #--------------------------------------------------------------------------------------------------
 # WEB SERVER
 # Web server is executed in a dedicated Java process. By default heap size is @webDefaultHeapSize@.