diff --git a/hbase-handler/src/java/org/apache/hadoop/hive/hbase/HBaseStorageHandler.java b/hbase-handler/src/java/org/apache/hadoop/hive/hbase/HBaseStorageHandler.java index 255ffa2..fb73248 100644 --- a/hbase-handler/src/java/org/apache/hadoop/hive/hbase/HBaseStorageHandler.java +++ b/hbase-handler/src/java/org/apache/hadoop/hive/hbase/HBaseStorageHandler.java @@ -29,6 +29,7 @@ import java.util.Properties; import java.util.Set; +import org.apache.commons.io.IOUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HColumnDescriptor; @@ -150,6 +151,8 @@ public void preCreateTable(Table tbl) throws MetaException { throw new MetaException("LOCATION may not be specified for HBase."); } + HTable htable = null; + try { String tableName = getHBaseTableName(tbl); Map serdeParam = tbl.getSd().getSerdeInfo().getParameters(); @@ -206,9 +209,13 @@ public void preCreateTable(Table tbl) throws MetaException { } // ensure the table is online - new HTable(hbaseConf, tableDesc.getName()); + htable = new HTable(hbaseConf, tableDesc.getName()); } catch (Exception se) { throw new MetaException(StringUtils.stringifyException(se)); + } finally { + if (htable != null) { + IOUtils.closeQuietly(htable); + } } }