huaxiangsun commented on a change in pull request #2753:
URL: https://github.com/apache/hbase/pull/2753#discussion_r538802217



##########
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionInfo.java
##########
@@ -363,7 +363,23 @@ static TableName getTable(final byte [] regionName) {
   @InterfaceAudience.Private // For use by internals only.
   public static boolean isEncodedRegionName(byte[] regionName) {
     // If not parseable as region name, presume encoded. TODO: add stringency; 
e.g. if hex.
-    return parseRegionNameOrReturnNull(regionName) == null && 
regionName.length <= MD5_HEX_LENGTH;
+    if (parseRegionNameOrReturnNull(regionName) == null) {
+      if (regionName.length > MD5_HEX_LENGTH) {
+        return false;
+      } else if (regionName.length == MD5_HEX_LENGTH) {
+        return true;
+      } else {
+        String encodedName = Bytes.toString(regionName);
+        try {
+          Integer.parseInt(encodedName);
+          // If this is a valid integer, it could be hbase:meta's encoded 
region name.
+          return true;
+        } catch(NumberFormatException er) {
+          return false;
+        }
+      }
+    }
+    return false;

Review comment:
       The new test case testCompactATableWithSuperLongTableName() is for this 
purpose. 
   It calls majorCompactRegion() for tableName with length over 32 bytes and 
tested a short-length table name, expecting it throw out the expected exception.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to