From 7a9d22a005d1f0b80a161149c967f149576a46ac Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 30 Sep 2015 12:17:19 +0200 Subject: [PATCH] SONAR-6886 Stop support of deprecated property sonar.jdbc.user --- .../src/main/java/org/sonar/db/DefaultDatabase.java | 10 +--------- .../test/java/org/sonar/db/DefaultDatabaseTest.java | 12 ------------ .../org/sonar/api/database/DatabaseProperties.java | 5 +++++ 3 files changed, 6 insertions(+), 21 deletions(-) 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"; -- 2.39.5