Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-27928

listTableNames has different criteria for judging the regular matching of tables in the default namespace

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.0.0
    • None
    • Admin
    • None

    Description

      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

      String tableNameRegex = "^(test).*";
      TableName[] tns = admin.listTableNames(Pattern.compile(tableNameRegex));

      When I execute the following logic (get a table that doesn't start with test), the return is order_info, test123

      String tableNameRegex = "^(?!test).*";
      TableName[] tns = admin.listTableNames(Pattern.compile(tableNameRegex));

      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.

      boolean matched = pattern.matcher(tableName).matches();
      if (!matched && htd.getTableName().getNamespaceAsString().equals(defaultNS)) {
          matched = pattern.matcher(defaultNS + TableName.NAMESPACE_DELIM + tableName).matches();
      }

       

      I think there are problems with this regular matching logic

       

      Attachments

        Activity

          People

            SWH12 wenhao
            SWH12 wenhao
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: