]> source.dussan.org Git - sonarqube.git/commitdiff
Allow try-with-resources with SqlStatement in DB migrations
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 25 Aug 2016 14:28:33 +0000 (16:28 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 5 Sep 2016 09:32:16 +0000 (11:32 +0200)
sonar-db/src/main/java/org/sonar/db/version/BaseSqlStatement.java
sonar-db/src/main/java/org/sonar/db/version/SqlStatement.java

index 27e125631327e045fe1ce681ed123a4c9760377a..6b465a78952ebab3b44a64056cbc0469281455ec 100644 (file)
@@ -35,10 +35,9 @@ class BaseSqlStatement<CHILD extends SqlStatement> implements SqlStatement<CHILD
   }
 
   @Override
-  public CHILD close() {
+  public void close() {
     DbUtils.closeQuietly(pstmt);
     pstmt = null;
-    return (CHILD) this;
   }
 
   @Override
index 28924c538a1d416160beb16e5a1fe647e6ce0505..4158aee2b776e2d1268f10a936879faccd426061 100644 (file)
@@ -23,7 +23,7 @@ import java.sql.SQLException;
 import java.util.Date;
 import javax.annotation.Nullable;
 
-public interface SqlStatement<CHILD extends SqlStatement> {
+public interface SqlStatement<CHILD extends SqlStatement> extends AutoCloseable {
   CHILD setBoolean(int columnIndex, @Nullable Boolean value) throws SQLException;
 
   CHILD setDate(int columnIndex, @Nullable Date value) throws SQLException;
@@ -38,5 +38,6 @@ public interface SqlStatement<CHILD extends SqlStatement> {
 
   CHILD setBytes(int columnIndex, @Nullable byte[] data) throws SQLException;
 
-  CHILD close();
+  @Override
+  void close();
 }