From c96566d0224301109716d45992b17f39bfbe1063 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Sat, 12 Mar 2011 06:34:26 +0000 Subject: [PATCH] HBASE-3538 Column families allow to have slashes in name git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1080870 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + .../apache/hadoop/hbase/HColumnDescriptor.java | 2 +- .../org/apache/hadoop/hbase/client/TestAdmin.java | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index d886ea0b877..3e0dd8aacea 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -65,6 +65,7 @@ Release 0.91.0 - Unreleased HBASE-3612 HBaseAdmin::isTableAvailable returns true when the table does not exit HBASE-3626 Update instructions in thrift demo files (Moaz Reyad via Stack) + HBASE-3538 Column families allow to have slashes in name (Ian Knome via Stack) IMPROVEMENTS HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack) diff --git a/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java b/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java index 8808c0649b6..8353dd9f55b 100644 --- a/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java +++ b/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java @@ -284,7 +284,7 @@ public class HColumnDescriptor implements WritableComparable "period: " + Bytes.toString(b)); } for (int i = 0; i < b.length; i++) { - if (Character.isISOControl(b[i]) || b[i] == ':') { + if (Character.isISOControl(b[i]) || b[i] == ':' || b[i] == '\\' || b[i] == '/') { throw new IllegalArgumentException("Illegal character <" + b[i] + ">. Family names cannot contain control characters or colons: " + Bytes.toString(b)); diff --git a/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java b/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java index 7e8f9da3bc8..63794c374cf 100644 --- a/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java +++ b/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java @@ -148,6 +148,16 @@ public class TestAdmin { assertEquals(htd.compareTo(confirmedHtd), 0); } + @Test + public void testHColumnValidName() { + boolean exceptionThrown = false; + try { + HColumnDescriptor fam1 = new HColumnDescriptor("\\test\\abc"); + } catch(IllegalArgumentException iae) { + exceptionThrown = true; + assertTrue(exceptionThrown); + } + } /** * Verify schema modification takes. * @throws IOException @@ -622,6 +632,11 @@ public class TestAdmin { this.admin.createTable(new HTableDescriptor()); } + @Test (expected=IllegalArgumentException.class) + public void testInvalidHColumnDescriptor() throws IOException { + HColumnDescriptor hcd = new HColumnDescriptor("/cfamily/name"); + } + @Test public void testEnableDisableAddColumnDeleteColumn() throws Exception { byte [] tableName = Bytes.toBytes("testMasterAdmin");