diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2019-12-09 09:34:43 -0600 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-12-10 20:46:09 +0100 |
commit | d1fd889554bccbb50122550899dbb66b90b04f78 (patch) | |
tree | 9cad838366292ee79b77ac3513403f7489b06355 /server/sonar-db-core | |
parent | f86a1094588e4e47b3abf612891af0431653cd0e (diff) | |
download | sonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.tar.gz sonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.zip |
Fix code quality issues and reduce dependency on Guava
Diffstat (limited to 'server/sonar-db-core')
4 files changed, 6 insertions, 7 deletions
diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingPreparedStatementHandler.java b/server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingPreparedStatementHandler.java index fe3f2845d8e..5b665121e8f 100644 --- a/server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingPreparedStatementHandler.java +++ b/server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingPreparedStatementHandler.java @@ -40,7 +40,7 @@ class ProfilingPreparedStatementHandler implements InvocationHandler { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getName().startsWith("execute")) { Profiler profiler = Profiler.create(ProfiledDataSource.SQL_LOGGER).start(); - Object result = null; + Object result; try { result = InvocationUtils.invokeQuietly(statement, method, args); } finally { diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingStatementHandler.java b/server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingStatementHandler.java index 92b4373b311..88b2119027e 100644 --- a/server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingStatementHandler.java +++ b/server/sonar-db-core/src/main/java/org/sonar/db/profiling/ProfilingStatementHandler.java @@ -36,7 +36,7 @@ class ProfilingStatementHandler implements InvocationHandler { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getName().startsWith("execute")) { Profiler profiler = Profiler.create(ProfiledDataSource.SQL_LOGGER).start(); - Object result = null; + Object result; try { result = InvocationUtils.invokeQuietly(statement, method, args); } finally { diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/DatabaseUtilsTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/DatabaseUtilsTest.java index 40ee287d0e6..3d3fe1d03f5 100644 --- a/server/sonar-db-core/src/test/java/org/sonar/db/DatabaseUtilsTest.java +++ b/server/sonar-db-core/src/test/java/org/sonar/db/DatabaseUtilsTest.java @@ -146,7 +146,7 @@ public class DatabaseUtilsTest { public void toUniqueAndSortedList_throws_NPE_if_arg_is_a_set_containing_a_null() { expectedException.expect(NullPointerException.class); - toUniqueAndSortedList(new HashSet<>(asList("A", (String) null, "C"))); + toUniqueAndSortedList(new HashSet<>(asList("A", null, "C"))); } @Test diff --git a/server/sonar-db-core/src/testFixtures/java/org/sonar/db/AbstractDbTester.java b/server/sonar-db-core/src/testFixtures/java/org/sonar/db/AbstractDbTester.java index 0b9bb16bc6e..4c7b2f35584 100644 --- a/server/sonar-db-core/src/testFixtures/java/org/sonar/db/AbstractDbTester.java +++ b/server/sonar-db-core/src/testFixtures/java/org/sonar/db/AbstractDbTester.java @@ -37,6 +37,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Date; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -54,8 +55,6 @@ import org.sonar.core.util.stream.MoreCollectors; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.collect.Lists.asList; -import static com.google.common.collect.Lists.newArrayList; -import static com.google.common.collect.Maps.newHashMap; import static java.sql.ResultSetMetaData.columnNoNulls; import static java.sql.ResultSetMetaData.columnNullable; import static org.assertj.core.api.Assertions.assertThat; @@ -209,9 +208,9 @@ public class AbstractDbTester<T extends TestDb> extends ExternalResource { private static List<Map<String, Object>> getHashMap(ResultSet resultSet) throws Exception { ResultSetMetaData metaData = resultSet.getMetaData(); int colCount = metaData.getColumnCount(); - List<Map<String, Object>> rows = newArrayList(); + List<Map<String, Object>> rows = new ArrayList<>(); while (resultSet.next()) { - Map<String, Object> columns = newHashMap(); + Map<String, Object> columns = new HashMap<>(); for (int i = 1; i <= colCount; i++) { Object value = resultSet.getObject(i); if (value instanceof Clob) { |