Return-Path: X-Original-To: apmail-hbase-issues-archive@www.apache.org Delivered-To: apmail-hbase-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 13FC617C38 for ; Tue, 17 Feb 2015 08:50:25 +0000 (UTC) Received: (qmail 19243 invoked by uid 500); 17 Feb 2015 08:50:12 -0000 Delivered-To: apmail-hbase-issues-archive@hbase.apache.org Received: (qmail 19201 invoked by uid 500); 17 Feb 2015 08:50:12 -0000 Mailing-List: contact issues-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@hbase.apache.org Received: (qmail 19189 invoked by uid 99); 17 Feb 2015 08:50:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Feb 2015 08:50:12 +0000 Date: Tue, 17 Feb 2015 08:50:12 +0000 (UTC) From: "Abhishek Kumar (JIRA)" To: issues@hbase.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HBASE-13050) Hbase shell create_namespace command throws ArrayIndexOutOfBoundException for (invalid) empty text input. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HBASE-13050?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14323943#comment-14323943 ] Abhishek Kumar commented on HBASE-13050: ---------------------------------------- Updated patch attached with empty Namespace test case (TestTableName.testEmptyNamespaceName) , pls take a look at it. > Hbase shell create_namespace command throws ArrayIndexOutOfBoundException for (invalid) empty text input. > --------------------------------------------------------------------------------------------------------- > > Key: HBASE-13050 > URL: https://issues.apache.org/jira/browse/HBASE-13050 > Project: HBase > Issue Type: Bug > Reporter: Abhishek Kumar > Priority: Trivial > Attachments: 0001-HBASE-13050-Empty-Namespace-name-validation.patch > > > {noformat} > 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) > {noformat} > 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: > {noformat} > 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)); > // > } > {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)