You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2017/07/22 13:39:59 UTC

kylin git commit: KYLIN-2701 KYLIN-2658 fix unclosed jdbc statements

Repository: kylin
Updated Branches:
  refs/heads/2.1.x 7ac68400c -> a2411fb4b


KYLIN-2701 KYLIN-2658 fix unclosed jdbc statements


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/a2411fb4
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/a2411fb4
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/a2411fb4

Branch: refs/heads/2.1.x
Commit: a2411fb4b0b9dcc36b1d6d4bb227b5a679d09496
Parents: 7ac6840
Author: shaofengshi <sh...@apache.org>
Authored: Sat Jul 22 21:39:50 2017 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Sat Jul 22 21:39:50 2017 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/kylin/rest/service/QueryService.java  | 5 +++--
 .../main/java/org/apache/kylin/source/jdbc/JdbcExplorer.java   | 6 ++++--
 2 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/a2411fb4/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java b/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java
index f3402ef..673b11b 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java
@@ -805,9 +805,9 @@ public class QueryService extends BasicService {
             List<List<String>> results, List<SelectedColumnMeta> columnMetas) throws SQLException {
 
         CalcitePrepareImpl.KYLIN_ONLY_PREPARE.set(true);
-
+        PreparedStatement preparedStatement = null;
         try {
-            conn.prepareStatement(correctedSql);
+            preparedStatement = conn.prepareStatement(correctedSql);
             throw new IllegalStateException("Should have thrown OnlyPrepareEarlyAbortException");
         } catch (Exception e) {
             Throwable rootCause = ExceptionUtils.getRootCause(e);
@@ -839,6 +839,7 @@ public class QueryService extends BasicService {
             }
         } finally {
             CalcitePrepareImpl.KYLIN_ONLY_PREPARE.set(false);
+            DBUtils.closeQuietly(preparedStatement);
         }
 
         return getSqlResponse(isPushDown, results, columnMetas);

http://git-wip-us.apache.org/repos/asf/kylin/blob/a2411fb4/source-hive/src/main/java/org/apache/kylin/source/jdbc/JdbcExplorer.java
----------------------------------------------------------------------
diff --git a/source-hive/src/main/java/org/apache/kylin/source/jdbc/JdbcExplorer.java b/source-hive/src/main/java/org/apache/kylin/source/jdbc/JdbcExplorer.java
index 25eacfc..7dc4e43 100644
--- a/source-hive/src/main/java/org/apache/kylin/source/jdbc/JdbcExplorer.java
+++ b/source-hive/src/main/java/org/apache/kylin/source/jdbc/JdbcExplorer.java
@@ -29,6 +29,7 @@ import java.util.UUID;
 
 import org.apache.hadoop.hive.ql.CommandNeedRetryException;
 import org.apache.kylin.common.KylinConfig;
+import org.apache.kylin.common.util.DBUtils;
 import org.apache.kylin.common.util.Pair;
 import org.apache.kylin.metadata.model.ColumnDesc;
 import org.apache.kylin.metadata.model.TableDesc;
@@ -232,6 +233,7 @@ public class JdbcExplorer implements ISourceMetadataExplorer, ISampleDataDeploye
         while (rs.next()){
             tableType = rs.getString(4);
         }
+        DBUtils.closeQuietly(rs);
         if (tableType!=null){
             tableDesc.setTableType(tableType);
         }else{
@@ -284,8 +286,8 @@ public class JdbcExplorer implements ISourceMetadataExplorer, ISampleDataDeploye
             cdesc.setId(String.valueOf(pos));
             columns.add(cdesc);
         }
-        
-        
+        DBUtils.closeQuietly(rs);
+
         tableDesc.setColumns(columns.toArray(new ColumnDesc[columns.size()]));
 
         TableExtDesc tableExtDesc = new TableExtDesc();