This is an automated email from the ASF dual-hosted git repository. jisaac pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push: new cdff86c0df PHOENIX-7605 Addendum Fixing IT where table was used after t.close(), passing pool to hbase client based on value. (#2152) cdff86c0df is described below commit cdff86c0df311aab8215b90e4c51108703ad618e Author: ritegarg <58840065+riteg...@users.noreply.github.com> AuthorDate: Thu May 15 13:25:05 2025 -0700 PHOENIX-7605 Addendum Fixing IT where table was used after t.close(), passing pool to hbase client based on value. (#2152) Co-authored-by: Ritesh Garg <ritesh.g...@riteshg-ltmd34g.internal.salesforce.com> --- .../src/main/java/org/apache/phoenix/query/HTableFactory.java | 11 ++++++++++- .../org/apache/phoenix/end2end/MappingTableDataTypeIT.java | 11 ++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/query/HTableFactory.java b/phoenix-core-client/src/main/java/org/apache/phoenix/query/HTableFactory.java index 79607df8e7..1d6c5d93da 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/query/HTableFactory.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/query/HTableFactory.java @@ -51,7 +51,16 @@ public interface HTableFactory { throws IOException { // If CQSI_THREAD_POOL_ENABLED then we pass ExecutorService created in CQSI to // HBase Client, else it is null(default), let the HBase client manage the thread pool - return connection.getTable(TableName.valueOf(tableName), pool); + // There is a difference between these 2 implementations in HBase Client Code and when + // the pool is terminated on HTable close() + // So we need to use these 2 implementations based on value of pool. + // If Externally provided pool is null, we use the default behavior of + // ConnectionImplementation to manage the pool. + if (pool == null) { + return connection.getTable(TableName.valueOf(tableName)); + } else { + return connection.getTable(TableName.valueOf(tableName), pool); + } } } } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MappingTableDataTypeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MappingTableDataTypeIT.java index f205467f2f..8527c69fba 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MappingTableDataTypeIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MappingTableDataTypeIT.java @@ -58,17 +58,16 @@ public class MappingTableDataTypeIT extends ParallelStatsDisabledIT { final TableName tableName = TableName.valueOf(mtest); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); PhoenixConnection conn = DriverManager.getConnection(getUrl(), props).unwrap(PhoenixConnection.class); - - Admin admin = conn.getQueryServices().getAdmin(); - try { + + try(Table t = conn.getQueryServices().getTable(Bytes.toBytes(mtest)); + Admin admin = conn.getQueryServices().getAdmin()) { // Create table then get the single region for our new table. TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName); builder.setColumnFamily(ColumnFamilyDescriptorBuilder.of(Bytes.toBytes("cf1"))) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(Bytes.toBytes("cf2"))); admin.createTable(builder.build()); - Table t = conn.getQueryServices().getTable(Bytes.toBytes(mtest)); + insertData(tableName.getName(), admin, t); - t.close(); // create phoenix table that maps to existing HBase table createPhoenixTable(mtest); @@ -99,8 +98,6 @@ public class MappingTableDataTypeIT extends ParallelStatsDisabledIT { assertEquals("Expected single value ", 1, kvs.size()); assertEquals("Column Value", "value2", Bytes.toString(kvs.get(0).getValueArray(), kvs.get(0).getValueOffset(), kvs.get(0).getValueLength())); assertNull("Expected single row", results.next()); - } finally { - admin.close(); } }