Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 39713200BAE for ; Fri, 14 Oct 2016 03:45:27 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 38118160AF6; Fri, 14 Oct 2016 01:45:27 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7EE18160AE4 for ; Fri, 14 Oct 2016 03:45:26 +0200 (CEST) Received: (qmail 12580 invoked by uid 500); 14 Oct 2016 01:45:25 -0000 Mailing-List: contact dev-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list dev@hbase.apache.org Received: (qmail 12568 invoked by uid 99); 14 Oct 2016 01:45:24 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Oct 2016 01:45:24 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 7CC5FC07A2 for ; Fri, 14 Oct 2016 01:45:24 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.249 X-Spam-Level: *** X-Spam-Status: No, score=3.249 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, KAM_INFOUSMEBIZ=0.75, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_SORBS_SPAM=0.5] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=commonvox-org.20150623.gappssmtp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id PmEv8uzrBfke for ; Fri, 14 Oct 2016 01:45:22 +0000 (UTC) Received: from mail-io0-f177.google.com (mail-io0-f177.google.com [209.85.223.177]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 80D7F5F396 for ; Fri, 14 Oct 2016 01:45:21 +0000 (UTC) Received: by mail-io0-f177.google.com with SMTP id r30so106529875ioi.1 for ; Thu, 13 Oct 2016 18:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=commonvox-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=96YoI8vnuVe7NYXa2h3/EE2jTG8CTFFP86Qa9rAzub8=; b=it18jUxT478IpGGf/M2fkf9RIENPPc2CprHVvwxXZTcD5aG51yQCDv366wRLg3KkMp SDpEULWaLhQa65FmmxqWFXAaVA7TNHEbpC1492Lv+jI/d0zp/FV/NzCVH99DGZz6ubmt cyhfWTAZ5tPr2wbs8LoDzKvo7n9xemThZOm+Y2w6ii5t7xRsdFYPuxebgt90WLT4/SVF r/G4CFvVjneBwqgMPN56bbJ5aIlzbwSkGj4DCHBXd8Qi/mCcwiQ4Z/FrxOhWvhq2ebKG yG+Pp08EeOK8zxl3bNR9+1wEnqW4MFVxJkzsbr1D6ZAsyWUL73P/34N5vlF/m/QnfAsv l54g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=96YoI8vnuVe7NYXa2h3/EE2jTG8CTFFP86Qa9rAzub8=; b=J4KijMeOoxXLjpSSQ1nzuyAGyz6d3nAvu7rIQ7N/jA26iUphkMraFnjRWLLBfXrN1X UfW7gnCA/hu9EcWDKxMBuhE8fsRTBfje72tRLBq5WqZTVPbXZSmddWv6MPLM23eCM1/n EyAzRqo1zM7wBedf/bQecyR9wwfj0ijSPgY2LwO5fmwVI94WhXdYS0tLWVb0awtAVbMs g5J+l90ezrCD1XZRe8xRy1yTZe0t0N7ley9SDUOYFg67V6xFJYJ0e5X9vhq70lC7w+7o RiZmtkiHqbcLct/Z61s/H1fdycCZi9g5/qQpFiN7jHapaMAINHuy1+sW4/Lr7GPFDkgU icZg== X-Gm-Message-State: AA6/9RmYVp3TWIokw/dNcmjM7CHlnLbQzN3kKQYn8kLxxQQvJugfj8HvQhrRnuhUcyP2twM2gQQBxSpHq1t1jQ== X-Received: by 10.107.39.66 with SMTP id n63mr11205632ion.180.1476409502549; Thu, 13 Oct 2016 18:45:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.3.211 with HTTP; Thu, 13 Oct 2016 18:45:02 -0700 (PDT) X-Originating-IP: [61.46.220.214] In-Reply-To: References: From: Daniel Vimont Date: Fri, 14 Oct 2016 10:45:02 +0900 Message-ID: Subject: Re: [DISCUSSION] Bugs in some of the OrderedBytes decode methods? To: dev@hbase.apache.org Content-Type: multipart/alternative; boundary=001a11407650f15be7053ec95f61 archived-at: Fri, 14 Oct 2016 01:45:27 -0000 --001a11407650f15be7053ec95f61 Content-Type: text/plain; charset=UTF-8 Agreed, Ted. But I wanted to be sure there wasn't some hidden reason for the current "assert"-only code. The only other possibility that came to mind is that there may be some interoperability issue(s) with external consumers of OrderedBytes (such as Phoenix) which requires that no exception be thrown by some of the #decode methods. Hoping that Nick D. can perhaps provide the final word on this. On Fri, Oct 14, 2016 at 9:29 AM, Ted Yu wrote: > I think throwing exception should be the action to take. > > Relying on assertion is not robust. > > > On Oct 13, 2016, at 5:06 PM, Daniel Vimont wrote: > > > > I'm currently looking into the various implementations of `DataType` in > > hbase-common, and I just wanted to get confirmation of something before I > > open up a JIRA and fix what **appear** to be bugs in the underlying > > OrderedBytes > > code. > > > > All `DataType` implementations have their own overrides of the `#decode` > > method. Some of these throw an appropriate exception when an invalid > > byte-array is passed to them; for example: > > > > *Number bogusNumeric = OrderedNumeric.ASCENDING.decode(new > > SimplePositionedMutableByteRange(Bytes.toBytes("xyzpdq")));* > > > > (This throws an IllegalArgumentException: "unexpected value in first > byte: > > 0x78".) > > > > But for other implementations, *no* validation is done; for example: > > > > *Short bogusShort = OrderedInt16.ASCENDING.decode(new > > SimplePositionedMutableByteRange(Bytes.toBytes("xyzpdq")));* > > > > (This returns a short value of 1669, without complaint -- by ignoring the > > first invalid "header" byte and constructing the value 1669 from the two > > bytes that follow.) > > > > In those implementations which lack validation, there are "assert" > > statements in the place where I would expect an exception to be > explicitly > > thrown (or, in the context of OrderedBytes, one would expect the > > #unexpectedHeader > > method to be invoked, which in turn throws the exception). I just wanted > to > > check to make sure whether (perhaps for the sake of extreme efficiency?) > > some validations in HBase low-level processing are intentionally being > done > > via bypassable "assert" statements instead of the throwing of exceptions. > > > > Thanks! > > > > Dan > > > > > > [image: --] > > > > Daniel Vimont > > [image: https://]about.me/dvimont > > email_sig&utm_medium=external_link&utm_campaign=chrome_ext> > --001a11407650f15be7053ec95f61--