wenhao created HBASE-27928:
------------------------------

             Summary: listTableNames has different criteria for judging the 
regular matching of tables in the default library
                 Key: HBASE-27928
                 URL: https://issues.apache.org/jira/browse/HBASE-27928
             Project: HBase
          Issue Type: Bug
          Components: Admin
    Affects Versions: 2.0.0
            Reporter: wenhao


There are the following tables under default: order_info, test123 

When I execute the following logic (get the table that starts with test), 
test123 is returned
{code:java}
String tableNameRegex = "^(test).*";
TableName[] tns = admin.listTableNames(Pattern.compile(tableNameRegex));{code}
When I execute the following logic (get a table that doesn't start with test), 
the return is order_info, test123
{code:java}
String tableNameRegex = "^(?!test).*";
TableName[] tns = admin.listTableNames(Pattern.compile(tableNameRegex));{code}
As you can see, table test123 is returned both times.

 

When I look at the source code, I find that when I perform a regular match for 
the table in the default namespace, I perform one step more judgment, resulting 
in a table starting with test being returned both times.
{code:java}
boolean matched = pattern.matcher(tableName).matches();
if (!matched && htd.getTableName().getNamespaceAsString().equals(defaultNS)) {
    matched = pattern.matcher(defaultNS + TableName.NAMESPACE_DELIM + 
tableName).matches();
}{code}
 

I think there are problems with this regular matching logic

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to