Skip to content

Commit

Permalink
Revert "fix bug: string out of bounds when construct illegal tablenam…
Browse files Browse the repository at this point in the history
…e error message (#2884)"

This reverts commit 9b6c135.
  • Loading branch information
saintstack committed Feb 8, 2021
1 parent 3c29eae commit 1d281ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,16 @@ public static void isLegalTableQualifierName(final byte[] qualifierName,
if(end - start < 1) {
throw new IllegalArgumentException(isSnapshot ? "Snapshot" : "Table" + " qualifier must not be empty");
}
String qualifierString = Bytes.toString(qualifierName, start, end - start);
if (qualifierName[start] == '.' || qualifierName[start] == '-') {
throw new IllegalArgumentException("Illegal first character <" + qualifierName[start] +
"> at 0. " + (isSnapshot ? "Snapshot" : "User-space table") +
" qualifiers can only start with 'alphanumeric " +
"characters' from any language: " +
qualifierString);
Bytes.toString(qualifierName, start, end));
}
// Treat the bytes as UTF-8
String qualifierString = new String(
qualifierName, start, (end - start), StandardCharsets.UTF_8);
if (qualifierString.equals(DISALLOWED_TABLE_NAME)) {
// Per https://zookeeper.apache.org/doc/r3.4.10/zookeeperProgrammers.html#ch_zkDataModel
// A znode named "zookeeper" is disallowed by zookeeper.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public int hashCode() {

@Test public void testIllegalHTableNames() {
for (String tn : illegalTableNames) {
assertThrows(IllegalArgumentException.class,
assertThrows(Exception.class,
() -> TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)));
}
}
Expand Down

0 comments on commit 1d281ef

Please sign in to comment.