Skip to content

Commit 16fe1e9

Browse files
committed
Revert "fix bug: string out of bounds when construct illegal tablename error message (#2884)"
This reverts commit 098f7c0.
1 parent 098f7c0 commit 16fe1e9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,16 @@ public static void isLegalTableQualifierName(final byte[] qualifierName,
192192
if(end - start < 1) {
193193
throw new IllegalArgumentException(isSnapshot ? "Snapshot" : "Table" + " qualifier must not be empty");
194194
}
195-
String qualifierString = Bytes.toString(qualifierName, start, end - start);
196195
if (qualifierName[start] == '.' || qualifierName[start] == '-') {
197196
throw new IllegalArgumentException("Illegal first character <" + qualifierName[start] +
198197
"> at 0. " + (isSnapshot ? "Snapshot" : "User-space table") +
199198
" qualifiers can only start with 'alphanumeric " +
200199
"characters' from any language: " +
201-
qualifierString);
200+
Bytes.toString(qualifierName, start, end));
202201
}
202+
// Treat the bytes as UTF-8
203+
String qualifierString = new String(
204+
qualifierName, start, (end - start), StandardCharsets.UTF_8);
203205
if (qualifierString.equals(DISALLOWED_TABLE_NAME)) {
204206
// Per https://zookeeper.apache.org/doc/r3.4.10/zookeeperProgrammers.html#ch_zkDataModel
205207
// A znode named "zookeeper" is disallowed by zookeeper.

hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public int hashCode() {
137137

138138
@Test public void testIllegalHTableNames() {
139139
for (String tn : illegalTableNames) {
140-
assertThrows(IllegalArgumentException.class,
140+
assertThrows(Exception.class,
141141
() -> TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)));
142142
}
143143
}

0 commit comments

Comments
 (0)