Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-1184

HColumnDescriptor is a little too restrictive with family names

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.19.0
    • 0.19.1, 0.20.0
    • None
    • None

    Description

      HColumnDescriptor crrently requires of its family names that they be letters, digits, underscores or periods.

      Character.isLetterOrDigit(b[i]) || b[i] == '_' || b[i] == '.'

      It would be nice if it let rather more characters be used (personally, I'd like to use a hyphen!)

      Attachments

        1. family-name.patch
          0.9 kB
          Toby White

        Activity

          tow21 Toby White added a comment - - edited

          The patch below fixes the issue.

          It reverses the sense of the test, and simply tests that each character is not a control character.

          It also tidies up the error message slightly (removing the reference to ending with colons, since that is tested in a separate check)

          Index: src/java/org/apache/hadoop/hbase/HColumnDescriptor.java
          ===================================================================
          — src/java/org/apache/hadoop/hbase/HColumnDescriptor.java (revision 740857)
          +++ src/java/org/apache/hadoop/hbase/HColumnDescriptor.java (working copy)
          @@ -242,12 +242,11 @@
          Bytes.toString(b));
          }
          for (int i = 0; i < (b.length - 1); i++) {

          • if (Character.isLetterOrDigit(b[i]) || b[i] == '_' || b[i] == '.') {
          • continue;
            + if (Character.isISOControl(b[i])) { + throw new IllegalArgumentException("Illegal character <" + b[i] + + ">. Family names cannot contain control characters: " + + Bytes.toString(b)); }
          • throw new IllegalArgumentException("Illegal character <" + b[i] +
          • ">. Family names can only contain 'word characters' and must end" +
          • "with a colon: " + Bytes.toString(b));
            }
            return b;
            }
          tow21 Toby White added a comment - - edited The patch below fixes the issue. It reverses the sense of the test, and simply tests that each character is not a control character. It also tidies up the error message slightly (removing the reference to ending with colons, since that is tested in a separate check) Index: src/java/org/apache/hadoop/hbase/HColumnDescriptor.java =================================================================== — src/java/org/apache/hadoop/hbase/HColumnDescriptor.java (revision 740857) +++ src/java/org/apache/hadoop/hbase/HColumnDescriptor.java (working copy) @@ -242,12 +242,11 @@ Bytes.toString(b)); } for (int i = 0; i < (b.length - 1); i++) { if (Character.isLetterOrDigit(b [i] ) || b [i] == '_' || b [i] == '.') { continue; + if (Character.isISOControl(b [i] )) { + throw new IllegalArgumentException("Illegal character <" + b[i] + + ">. Family names cannot contain control characters: " + + Bytes.toString(b)); } throw new IllegalArgumentException("Illegal character <" + b [i] + ">. Family names can only contain 'word characters' and must end" + "with a colon: " + Bytes.toString(b)); } return b; }
          apurtell Andrew Kyle Purtell added a comment - - edited

          Toby, Jira mangled your inline patch. Can you attach it as a file? Thanks.

          apurtell Andrew Kyle Purtell added a comment - - edited Toby, Jira mangled your inline patch. Can you attach it as a file? Thanks.
          tow21 Toby White added a comment -

          patch attached as file

          tow21 Toby White added a comment - patch attached as file

          Passes all tests. Committed to trunk and 0.19 branch.

          apurtell Andrew Kyle Purtell added a comment - Passes all tests. Committed to trunk and 0.19 branch.

          People

            apurtell Andrew Kyle Purtell
            tow21 Toby White
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: