diff options
5 files changed, 13 insertions, 12 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; diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/TestUtils.java b/sonar-testing-harness/src/main/java/org/sonar/test/TestUtils.java index 3c73db9cf53..55245b5f56b 100644 --- a/sonar-testing-harness/src/main/java/org/sonar/test/TestUtils.java +++ b/sonar-testing-harness/src/main/java/org/sonar/test/TestUtils.java @@ -133,13 +133,13 @@ public final class TestUtils { assertThat(file.exists(), is(true)); } - public static void assertSimilarXml(String expectedXml, String xml) throws IOException, SAXException { + public static void assertSimilarXml(String expectedXml, String xml) throws Exception { Diff diff = isSimilarXml(expectedXml, xml); String message = "Diff: " + diff.toString() + CharUtils.LF + "XML: " + xml; assertTrue(message, diff.similar()); } - static Diff isSimilarXml(String expectedXml, String xml) throws IOException, SAXException { + static Diff isSimilarXml(String expectedXml, String xml) throws Exception { XMLUnit.setIgnoreWhitespace(true); return XMLUnit.compareXML(xml, expectedXml); } |