Return-Path: Delivered-To: apmail-incubator-cassandra-dev-archive@minotaur.apache.org Received: (qmail 94051 invoked from network); 17 Jun 2009 00:52:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 Jun 2009 00:52:11 -0000 Received: (qmail 50906 invoked by uid 500); 17 Jun 2009 00:52:22 -0000 Delivered-To: apmail-incubator-cassandra-dev-archive@incubator.apache.org Received: (qmail 50870 invoked by uid 500); 17 Jun 2009 00:52:22 -0000 Mailing-List: contact cassandra-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cassandra-dev@incubator.apache.org Delivered-To: mailing list cassandra-dev@incubator.apache.org Received: (qmail 50860 invoked by uid 99); 17 Jun 2009 00:52:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Jun 2009 00:52:22 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of edward.ribeiro@gmail.com designates 209.85.217.206 as permitted sender) Received: from [209.85.217.206] (HELO mail-gx0-f206.google.com) (209.85.217.206) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Jun 2009 00:52:13 +0000 Received: by gxk2 with SMTP id 2so7155608gxk.12 for ; Tue, 16 Jun 2009 17:51:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=fzM4QO8W7WKY+Tn5ThtGVBB/SgbGzvt6+LGXE0vnWno=; b=g3ewRKS4sXKt7i2C0CO6MLmBlYZI8/d3JSCmbKKewJTfZ7g5nqf51BaUZram+OD4lt j02NKBGawy+meP/kplT+yWYW/4HTRJTOu5xsH5oXdKuIoT28RNaSU4pFPXpPSfoPVTsc dqIDJxDm9y4WulSsEEYovbYD6AGMGmaLIgfH4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=YmBSXjFaa59EtsdbgCRxnXBSHoLnNOp4bjE2iBIhOLZ8tUYiUspgkfscKdHZtp/oss HBf8DwVE+uWvqScfBQUzUCyE6Nmr6zl66nke/MrQSNW7ee6pt4KXgSQ5/U/ddrL4ZA3v DwYJTIA29edKJka4vGNCdRqSy6YzqTr0+Qoik= MIME-Version: 1.0 Received: by 10.151.137.10 with SMTP id p10mr16816737ybn.218.1245199912527; Tue, 16 Jun 2009 17:51:52 -0700 (PDT) In-Reply-To: References: <123dcca0906161731t3894f054n128a0115964ddee4@mail.gmail.com> Date: Tue, 16 Jun 2009 21:51:52 -0300 Message-ID: <123dcca0906161751n77370b38r7e8e607ee6164faa@mail.gmail.com> Subject: Re: Column assert From: Edward Ribeiro To: cassandra-dev@incubator.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org That's alright. Edward On Tue, Jun 16, 2009 at 9:45 PM, Jonathan Ellis wrote: > checking user input is done with explicit if statements; verifying > internal assumptions is done with asserts. =A0Column is not a > user-facing class (that would be column_t). > > -Jonathan > > On Tue, Jun 16, 2009 at 7:31 PM, Edward Ribeiro= wrote: >> =A0 Dear developers, >> >> =A0 I saw the following piece of the code in the Column class: >> >> =A0 =A0Column(String name, byte[] value, long timestamp, boolean isDelet= ed) >> =A0 =A0{ >> =A0 =A0 =A0 =A0assert name !=3D null; >> =A0 =A0 =A0 =A0assert value !=3D null; >> =A0 =A0 =A0 =A0[ ... ] >> =A0 =A0} >> >> Well, the assert is a debug facility and it should not be used in >> production code, because it only throws an exception when the code is >> run with the -ea switch. There are other classes that follow the same >> behaviour in Cassandra code base. If this is being used in place of a >> null checking "if" statement then I would be glad to submit a couple >> of patches to fix that. >> >> By the way, I saw that Cassandra project currently uses the very good >> google collections library. Therefore, the code can become even more >> succint like: >> >> import static com.google.common.base.Preconditions.*; >> >> [...] >> >> =A0 =A0Column(String name, byte[] value, long timestamp, boolean isDelet= ed) >> =A0 =A0{ >> =A0 =A0 =A0 =A0 =A0assertNotNull(name,"Column name cannot be null!"); >> =A0 =A0 =A0 =A0 =A0assertNotNull(value, "Byte array cannot be null!"); >> =A0 =A0 =A0 =A0 =A0[...] >> =A0 =A0 } >> >> Best regards, >> Edward >> >