]> source.dussan.org Git - sonarqube.git/commitdiff
Missing close of ResultSet in AnalysisReportDao
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 22 Jan 2015 17:09:04 +0000 (18:09 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 22 Jan 2015 17:09:04 +0000 (18:09 +0100)
 (even if it's not supposed to be needed as RS is closed by Statement)

server/sonar-server/src/main/java/org/sonar/server/computation/db/AnalysisReportDao.java
server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleCacheLoader.java

index d1778622f6046015769cf6c1c8b71b4442b70d48..ea34aa8176070fd4145e4442ad1a29caf46286a6 100644 (file)
@@ -156,7 +156,7 @@ public class AnalysisReportDao implements DaoComponent {
     Connection connection = session.getConnection();
     InputStream stream = null;
     PreparedStatement ps = null;
-    ResultSet rs;
+    ResultSet rs = null;
     try {
       ps = connection.prepareStatement("select report_data from analysis_reports where id=?");
       ps.setLong(1, id);
@@ -175,6 +175,7 @@ public class AnalysisReportDao implements DaoComponent {
       throw new IllegalStateException(String.format("Failed to decompress report '%d'", id), e);
     } finally {
       IOUtils.closeQuietly(stream);
+      DatabaseUtils.closeQuietly(rs);
       DatabaseUtils.closeQuietly(ps);
     }
   }
index c6936344a6c112aa84e6ed490f7b07b0f5e0f2a1..e6439fd5baa83896bf83cc555437af2db5ce484e 100644 (file)
@@ -21,6 +21,7 @@ package org.sonar.server.computation.issue;
 
 import org.sonar.api.rule.RuleKey;
 import org.sonar.core.persistence.DbSession;
+import org.sonar.core.persistence.MyBatis;
 import org.sonar.core.rule.RuleDto;
 import org.sonar.server.db.DbClient;
 import org.sonar.server.util.cache.CacheLoader;
@@ -42,7 +43,7 @@ public class RuleCacheLoader implements CacheLoader<RuleKey, RuleDto> {
     try {
       return dbClient.ruleDao().getNullableByKey(session, key);
     } finally {
-      session.close();
+      MyBatis.closeQuietly(session);
     }
   }