hbase开发问题-PooledHTable多次close导致问题

PooledHTable多次close导致问题

PooledHTableclose时,调用returnTable(table)

private void returnTable(HTableInterface table) throws IOException {
    // this is the old putTable method renamed and made private
    String tableName = Bytes.toString(table.getTableName());
    if (tables.size(tableName) >= maxSize) {
      // release table instance since we're not reusing it
      this.tables.remove(tableName, table);
      this.tableFactory.releaseHTableInterface(table);
      return;
    }
    tables.put(tableName, table);
  }

当对于同一个PooledHTable多次close时,

当tables.size(tableName)<maxSize时,

引用返回给了pool。

当tables.size(tableName)>=maxSize时,

代码执行到

this.tableFactory.releaseHTableInterface(table)

public void close() throws IOException {
    if (this.closed) {
      return;
    }
    flushCommits();
    if (cleanupPoolOnClose) {
      this.pool.shutdown();
    }
    if (cleanupConnectionOnClose) {
      if (this.connection != null) {
        this.connection.close();
      }
    }
    this.closed = true;
  }

该HTable被close了。

由于多个引用指向同一个HTable。当后续从HTablePool取到该HTable时,由于该HTable已经关闭,调用时报错。