incubator-cassandra-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edward Ribeiro <edward.ribe...@gmail.com>
Subject Column assert
Date Wed, 17 Jun 2009 00:31:23 GMT
   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