Skip to content


Subversion checkout URL

You can clone with
Download ZIP


TrySetValue with null value throws a NullReferenceException rather than returning false #118

kmbnw opened this Issue · 0 comments

2 participants


When I use TrySetValue with a null value, I get a null pointer exception, rather than the expected boolean return of false:

System.NullReferenceException : Object reference not set to an instance of an object.
at FluentCassandra.FluentColumn.set_ColumnValue(CassandraObject value) in F:\github\fluentcassandra\src\FluentColumn.cs:line 61
at FluentCassandra.FluentColumnFamily.TrySetColumn(Object name, Object value) in F:\github\fluentcassandra\src\FluentColumnFamily.cs:line 239

I note that the setter for ColumnValue in FluentColumn assumes that 'value' is not null and just attempts to

_value = value.GetValue(GetSchema().ValueType);

For reference, I'm using commit head c210cdd.

Repro code (based loosely on the unit tests in the FluentCassandra source tree):

var builder = new ConnectionBuilder(
    keyspace, serverName, connectionTimeout: 5, cqlVersion: CqlVersion.Cql)

using (var db = new CassandraContext(builder))
    var key = "first-blog-post";
    var postFamily = db.GetColumnFamily(columnFamily);
    var post = postFamily.CreateRecord(key: key);

    post.TrySetColumn("Title", null);
    // This also fails
    // post["Title"] = null;
    post["Body"] = "Just a Test";
@nberardi nberardi was assigned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.