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 A7D52D3FD for ; Fri, 24 May 2013 08:24:25 +0000 (UTC) Received: (qmail 33978 invoked by uid 500); 24 May 2013 08:24:25 -0000 Delivered-To: apmail-hbase-issues-archive@hbase.apache.org Received: (qmail 33678 invoked by uid 500); 24 May 2013 08:24:24 -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 33597 invoked by uid 99); 24 May 2013 08:24:22 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 May 2013 08:24:22 +0000 Date: Fri, 24 May 2013 08:24:21 +0000 (UTC) From: "samar (JIRA)" To: issues@hbase.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HBASE-7278) Some bugs of HTableDesciptor 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-7278?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13666100#comment-13666100 ] samar commented on HBASE-7278: ------------------------------ can we create a seperate jira to remove setName(byte[] name)? isLegalTableName() since its returning what is passed we can name it something like void validateTableName(), where we would not expect anything in return but will do all the checks as already implemented > Some bugs of HTableDesciptor > ---------------------------- > > Key: HBASE-7278 > URL: https://issues.apache.org/jira/browse/HBASE-7278 > Project: HBase > Issue Type: Bug > Reporter: Hiroshi Ikeda > Priority: Minor > > There are some bugs of the class HTableDescriptor. > {code} > public HTableDescriptor(final byte [] name) { > super(); > setMetaFlags(this.name); > this.name = this.isMetaRegion()? name: isLegalTableName(name); > this.nameAsString = Bytes.toString(this.name); > } > {code} > I think "setMetaFlags(this.name)" should be "setMetaFlags(name)". > {code} > /** > * Check passed byte buffer, "tableName", is legal user-space table name. > * @return Returns passed tableName param > * @throws NullPointerException If passed tableName is null > * @throws IllegalArgumentException if passed a tableName > * that is made of other than 'word' characters or underscores: i.e. > * [a-zA-Z_0-9]. > */ > public static byte [] isLegalTableName(final byte [] tableName) { > if (tableName == null || tableName.length <= 0) { > throw new IllegalArgumentException("Name is null or empty"); > } > {code} > The implementation is against the contract of throwing NullPointerException. > I'm not sure the contract is wrong or the implementation is wrong. > Also the contract of throwing IllegalArgumentException is a little different from the actual implementation, and in general we must actually call this method and catch IllegalArgumentException in order to know whether the given name can be used as a table name. > I feel HTableDescriptor allows itself to be in invalid states, and I cannot fix the class well. > I think we should start to remove implementing WritableComparable, but it might greatly break the compatibility. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira