HADOOP-2156 BufferUnderflowException for un-named HTableDescriptors

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@592551 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2007-11-06 20:48:27 +00:00
parent 9be624fc93
commit 656cee4138
4 changed files with 20 additions and 8 deletions

View File

@ -27,6 +27,7 @@ Trunk (unreleased changes)
the test more deterministic and getting META reassigned was the test more deterministic and getting META reassigned was
problematic. problematic.
HADOOP-2155 Method expecting HBaseConfiguration throws NPE when given Configuration HADOOP-2155 Method expecting HBaseConfiguration throws NPE when given Configuration
HADOOP-2156 BufferUnderflowException for un-named HTableDescriptors
IMPROVEMENTS IMPROVEMENTS
HADOOP-2401 Add convenience put method that takes writable HADOOP-2401 Add convenience put method that takes writable

View File

@ -112,7 +112,6 @@ public class HBaseAdmin implements HConstants {
*/ */
public void createTable(HTableDescriptor desc) public void createTable(HTableDescriptor desc)
throws IOException { throws IOException {
createTableAsync(desc); createTableAsync(desc);
// Wait for new table to come on-line // Wait for new table to come on-line
@ -134,15 +133,12 @@ public class HBaseAdmin implements HConstants {
*/ */
public void createTableAsync(HTableDescriptor desc) public void createTableAsync(HTableDescriptor desc)
throws IOException { throws IOException {
if (this.master == null) { if (this.master == null) {
throw new MasterNotRunningException("master has been shut down"); throw new MasterNotRunningException("master has been shut down");
} }
checkReservedTableName(desc.getName()); checkReservedTableName(desc.getName());
try { try {
this.master.createTable(desc); this.master.createTable(desc);
} catch (RemoteException e) { } catch (RemoteException e) {
throw RemoteExceptionHandler.decodeRemoteException(e); throw RemoteExceptionHandler.decodeRemoteException(e);
} }
@ -492,10 +488,12 @@ public class HBaseAdmin implements HConstants {
* @throws IllegalArgumentException - if the table name is reserved * @throws IllegalArgumentException - if the table name is reserved
*/ */
protected void checkReservedTableName(Text tableName) { protected void checkReservedTableName(Text tableName) {
if (tableName == null || tableName.getLength() <= 0) {
throw new IllegalArgumentException("Null or empty table name");
}
if(tableName.charAt(0) == '-' || if(tableName.charAt(0) == '-' ||
tableName.charAt(0) == '.' || tableName.charAt(0) == '.' ||
tableName.find(",") != -1) { tableName.find(",") != -1) {
throw new IllegalArgumentException(tableName + " is a reserved table name"); throw new IllegalArgumentException(tableName + " is a reserved table name");
} }
} }

View File

@ -74,7 +74,11 @@ public class HTableDescriptor implements WritableComparable {
families.put(family.getName(), family); families.put(family.getName(), family);
} }
/** Constructs an empty object */ /**
* Constructs an empty object.
* For deserializing an HTableDescriptor instance only.
* @see #HTableDescriptor(String)
*/
public HTableDescriptor() { public HTableDescriptor() {
this.name = new Text(); this.name = new Text();
this.families = new TreeMap<Text, HColumnDescriptor>(); this.families = new TreeMap<Text, HColumnDescriptor>();

View File

@ -41,6 +41,15 @@ public class TestMasterAdmin extends HBaseClusterTestCase {
/** @throws Exception */ /** @throws Exception */
public void testMasterAdmin() throws Exception { public void testMasterAdmin() throws Exception {
admin = new HBaseAdmin(conf); admin = new HBaseAdmin(conf);
// Add test that exception is thrown if descriptor is without a table name.
// HADOOP-2156.
boolean exception = false;
try {
admin.createTable(new HTableDescriptor());
} catch (IllegalArgumentException e) {
exception = true;
}
assertTrue(exception);
admin.createTable(testDesc); admin.createTable(testDesc);
admin.disableTable(testDesc.getName()); admin.disableTable(testDesc.getName());