diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-09-21 14:38:19 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-09-21 14:38:19 +0200 |
commit | 1005aa3a90683235a985b365ae9b4b7446f17797 (patch) | |
tree | c6c72912b93b8d8f4b6d0cc1d24ce0da04fbb439 /sonar-server | |
parent | f8b016eaef578571f2b9d2f346a9949b779fc829 (diff) | |
download | sonarqube-1005aa3a90683235a985b365ae9b4b7446f17797.tar.gz sonarqube-1005aa3a90683235a985b365ae9b4b7446f17797.zip |
Fix some quality flaws
Diffstat (limited to 'sonar-server')
4 files changed, 11 insertions, 10 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrations.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrations.java index d20ef966380..982042cec98 100644 --- a/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrations.java +++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrations.java @@ -19,11 +19,15 @@ */ package org.sonar.server.db.migrations; +import com.google.common.collect.ImmutableList; import org.sonar.server.db.migrations.violation.ViolationMigration; +import java.util.List; + public interface DatabaseMigrations { - Class<? extends DatabaseMigration>[] CLASSES = new Class[]{ + List<Class<? extends DatabaseMigration>> CLASSES = ImmutableList.<Class<? extends DatabaseMigration>>of( ViolationMigration.class - }; + ); + } diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Referentials.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Referentials.java index c7accede562..2260b160f4d 100644 --- a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Referentials.java +++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Referentials.java @@ -70,15 +70,14 @@ class Referentials { return totalViolations; } - @CheckForNull Long[] pollGroupOfViolationIds() { long[] longs = groupsOfViolationIds.poll(); if (longs == null) { - return null; + return new Long[0]; } Long[] objects = new Long[longs.length]; for (int i = 0; i < longs.length; i++) { - objects[i] = new Long(longs[i]); + objects[i] = Long.valueOf(longs[i]); } return objects; } @@ -103,10 +102,10 @@ class Referentials { private Queue<long[]> initGroupOfViolationIds(Database database) throws SQLException { Connection connection = database.getDataSource().getConnection(); - connection.setAutoCommit(false); Statement stmt = null; ResultSet rs = null; try { + connection.setAutoCommit(false); stmt = connection.createStatement(); stmt.setFetchSize(10000); rs = stmt.executeQuery("select id from rule_failures"); diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverter.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverter.java index e0d39f1c7fc..de525fc2b31 100644 --- a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverter.java +++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverter.java @@ -138,7 +138,7 @@ class ViolationConverter implements Callable<Object> { // -- delete violations Long[] violationIds = referentials.pollGroupOfViolationIds(); - while (violationIds != null) { + while (violationIds.length>0) { List<Map<String, Object>> rows = selectRows(violationIds); convert(rows, violationIds); diff --git a/sonar-server/src/main/java/org/sonar/server/notifications/NotificationCenter.java b/sonar-server/src/main/java/org/sonar/server/notifications/NotificationCenter.java index df7b84c6d0a..c59d73ecbf1 100644 --- a/sonar-server/src/main/java/org/sonar/server/notifications/NotificationCenter.java +++ b/sonar-server/src/main/java/org/sonar/server/notifications/NotificationCenter.java @@ -89,10 +89,8 @@ public class NotificationCenter implements ServerComponent { for (NotificationDispatcherMetadata metadata : dispatchersMetadata) { String dispatcherKey = metadata.getDispatcherKey(); String value = metadata.getProperty(propertyKey); - if (value != null) { - if (propertyValue == null || value.equals(propertyValue)) { + if (value != null && (propertyValue == null || value.equals(propertyValue))) { keys.add(dispatcherKey); - } } } return keys; |