incubator-cassandra-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Ellis <jbel...@gmail.com>
Subject Re: Column assert
Date Wed, 17 Jun 2009 00:45:22 GMT
checking user input is done with explicit if statements; verifying
internal assumptions is done with asserts.  Column is not a
user-facing class (that would be column_t).

-Jonathan

On Tue, Jun 16, 2009 at 7:31 PM, Edward Ribeiro<edward.ribeiro@gmail.com> wrote:
>   Dear developers,
>
>   I saw the following piece of the code in the Column class:
>
>    Column(String name, byte[] value, long timestamp, boolean isDeleted)
>    {
>        assert name != null;
>        assert value != null;
>        [ ... ]
>    }
>
> 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.*;
>
> [...]
>
>    Column(String name, byte[] value, long timestamp, boolean isDeleted)
>    {
>          assertNotNull(name,"Column name cannot be null!");
>          assertNotNull(value, "Byte array cannot be null!");
>          [...]
>     }
>
> Best regards,
> Edward
>

Mime
View raw message