From: Simon Brandhof Date: Wed, 30 Sep 2015 10:17:19 +0000 (+0200) Subject: SONAR-6886 Stop support of deprecated property sonar.jdbc.user X-Git-Tag: 5.2-RC1~186 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7a9d22a005d1f0b80a161149c967f149576a46ac;p=sonarqube.git SONAR-6886 Stop support of deprecated property sonar.jdbc.user --- diff --git a/sonar-db/src/main/java/org/sonar/db/DefaultDatabase.java b/sonar-db/src/main/java/org/sonar/db/DefaultDatabase.java index cf71253f7f5..7bb864230f2 100644 --- a/sonar-db/src/main/java/org/sonar/db/DefaultDatabase.java +++ b/sonar-db/src/main/java/org/sonar/db/DefaultDatabase.java @@ -75,7 +75,7 @@ public class DefaultDatabase implements Database { void initSettings() { properties = new Properties(); completeProperties(settings, properties, SONAR_JDBC); - completeDefaultProperties(properties); + completeDefaultProperty(properties, DatabaseProperties.PROP_URL, DEFAULT_URL); doCompleteProperties(properties); dialect = DialectUtils.find(properties.getProperty(SONAR_JDBC_DIALECT), properties.getProperty(SONAR_JDBC_URL)); @@ -160,14 +160,6 @@ public class DefaultDatabase implements Database { return result; } - private static void completeDefaultProperties(Properties props) { - completeDefaultProperty(props, DatabaseProperties.PROP_URL, DEFAULT_URL); - - if (props.getProperty(DatabaseProperties.PROP_USER_DEPRECATED) != null) { - completeDefaultProperty(props, DatabaseProperties.PROP_USER, props.getProperty(DatabaseProperties.PROP_USER_DEPRECATED)); - } - } - private static void completeDefaultProperty(Properties props, String key, String defaultValue) { if (props.getProperty(key) == null) { props.setProperty(key, defaultValue); diff --git a/sonar-db/src/test/java/org/sonar/db/DefaultDatabaseTest.java b/sonar-db/src/test/java/org/sonar/db/DefaultDatabaseTest.java index 0d0c4ee1ad6..7eb9ad8e8a8 100644 --- a/sonar-db/src/test/java/org/sonar/db/DefaultDatabaseTest.java +++ b/sonar-db/src/test/java/org/sonar/db/DefaultDatabaseTest.java @@ -40,18 +40,6 @@ public class DefaultDatabaseTest { assertThat(db.toString()).isEqualTo("Database[jdbc:h2:tcp://localhost/sonar]"); } - @Test - public void shouldSupportDeprecatedUserProperty() { - Settings settings = new Settings(); - settings.setProperty("sonar.jdbc.user", "me"); - - DefaultDatabase db = new DefaultDatabase(settings); - db.initSettings(); - Properties props = db.getProperties(); - - assertThat(props.getProperty("sonar.jdbc.username")).isEqualTo("me"); - } - @Test public void shouldExtractCommonsDbcpProperties() { Properties props = new Properties(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseProperties.java index 7b427b3faf1..2bbea33ce7b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseProperties.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseProperties.java @@ -26,6 +26,11 @@ public interface DatabaseProperties { String PROP_URL = "sonar.jdbc.url"; String PROP_DRIVER = "sonar.jdbc.driverClassName"; String PROP_USER = "sonar.jdbc.username"; + + /** + * @deprecated not documented for a while (before version 3.6) and not supported since version 5.2. + */ + @Deprecated String PROP_USER_DEPRECATED = "sonar.jdbc.user"; String PROP_USER_DEFAULT_VALUE = ""; String PROP_PASSWORD = "sonar.jdbc.password";