Repository: kylin
Updated Branches:
  refs/heads/v1.6.0-rc1 207ab51dc -> c19d8e917


KYLIN-2138 Unclosed ResultSet in BeelineHiveClient


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

Branch: refs/heads/v1.6.0-rc1
Commit: c19d8e9176a5b10163184bd691e6d1928735343e
Parents: 207ab51
Author: shaofengshi <[email protected]>
Authored: Fri Nov 4 14:12:20 2016 +0800
Committer: shaofengshi <[email protected]>
Committed: Fri Nov 4 14:12:46 2016 +0800

----------------------------------------------------------------------
 .../kylin/source/hive/BeelineHiveClient.java    | 23 ++++++--------------
 1 file changed, 7 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/c19d8e91/source-hive/src/main/java/org/apache/kylin/source/hive/BeelineHiveClient.java
----------------------------------------------------------------------
diff --git 
a/source-hive/src/main/java/org/apache/kylin/source/hive/BeelineHiveClient.java 
b/source-hive/src/main/java/org/apache/kylin/source/hive/BeelineHiveClient.java
index a84aeb1..fb6ddc1 100644
--- 
a/source-hive/src/main/java/org/apache/kylin/source/hive/BeelineHiveClient.java
+++ 
b/source-hive/src/main/java/org/apache/kylin/source/hive/BeelineHiveClient.java
@@ -32,6 +32,7 @@ import org.apache.hadoop.hive.ql.CommandNeedRetryException;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
+import org.apache.kylin.common.util.DBUtils;
 
 public class BeelineHiveClient implements IHiveClient {
 
@@ -86,6 +87,7 @@ public class BeelineHiveClient implements IHiveClient {
         while (schemas.next()) {
             ret.add(String.valueOf(schemas.getObject(1)));
         }
+        DBUtils.closeQuietly(schemas);
         return ret;
     }
 
@@ -95,6 +97,7 @@ public class BeelineHiveClient implements IHiveClient {
         while (tables.next()) {
             ret.add(String.valueOf(tables.getObject(3)));
         }
+        DBUtils.closeQuietly(tables);
         return ret;
     }
 
@@ -118,11 +121,11 @@ public class BeelineHiveClient implements IHiveClient {
             allColumns.add(new 
HiveTableMeta.HiveTableColumnMeta(columns.getString(4), columns.getString(6), 
columns.getString(12)));
         }
         builder.setAllColumns(allColumns);
-
+        DBUtils.closeQuietly(columns);
         stmt.execute("use " + database);
         ResultSet resultSet = stmt.executeQuery("describe formatted " + 
tableName);
         extractHiveTableMeta(resultSet, builder);
-
+        DBUtils.closeQuietly(resultSet);
         return builder.createHiveTableMeta();
     }
 
@@ -187,20 +190,8 @@ public class BeelineHiveClient implements IHiveClient {
     }
 
     public void close() {
-        if (this.stmt != null) {
-            try {
-                this.stmt.close();
-            } catch (SQLException e) {
-                //
-            }
-        }
-        if (this.cnct != null) {
-            try {
-                this.cnct.close();
-            } catch (SQLException e) {
-                //
-            }
-        }
+        DBUtils.closeQuietly(stmt);
+        DBUtils.closeQuietly(cnct);
     }
 
     public static void main(String[] args) throws SQLException {

Reply via email to