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

Hbase shell create_namespace command throws ArrayIndexOutOfBoundException for (invalid) empty text input.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • None
    • 1.0.1, 1.1.0, 0.98.11, 2.0.0
    • None
    • None

    Description

      hbase(main):008:0> create_namespace ''
      
      ERROR: java.io.IOException: 0
              at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:2072)
              at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:107)
              at org.apache.hadoop.hbase.ipc.RpcExecutor.consumerLoop(RpcExecutor.java:130)
              at org.apache.hadoop.hbase.ipc.RpcExecutor$1.run(RpcExecutor.java:107)
              at java.lang.Thread.run(Thread.java:745)
      Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
              at org.apache.hadoop.hbase.TableName.isLegalNamespaceName(TableName.java:222)
              at org.apache.hadoop.hbase.TableName.isLegalNamespaceName(TableName.java:205)
      

      TableName.isLegalNamespaceName tries to access namespaceName[offset] in case of empty text input and also this check for 'offset==length' in this method seems to be unnecessary and an empty input validation check can be put in the beginning of this method instead:

       public static void isLegalNamespaceName(byte[] namespaceName, int offset, int length) {
      // can add empty check in the beginning 
        if(length == 0) {
            throw new IllegalArgumentException("Namespace name must not be empty");
          }
      // end
          for (int i = offset; i < length; i++) {
            if (Character.isLetterOrDigit(namespaceName[i])|| namespaceName[i] == '_') {
              continue;
            }
            throw new IllegalArgumentException("Illegal character <" + namespaceName[i] +
              "> at " + i + ". Namespaces can only contain " +
              "'alphanumeric characters': i.e. [a-zA-Z_0-9]: " + Bytes.toString(namespaceName,
                offset, length));
          }
       //  can remove below check
         if(offset == length)
            throw new IllegalArgumentException("Illegal character <" + _namespaceName[offset] _+
                "> at " + offset + ". Namespaces can only contain " +
                "'alphanumeric characters': i.e. [a-zA-Z_0-9]: " + Bytes.toString(namespaceName,
                  offset, length));
       // 
      }
      

      Attachments

        Activity

          People

            a72877 Abhishek Kumar
            a72877 Abhishek Kumar
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: