Uploaded image for project: 'Couchbase .NET client library'
  1. Couchbase .NET client library
  2. NCBC-373

.NET GetJSON operation throws System.ArgumentNullException

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.3.2
    • 1.3.1
    • library
    • None
    • .net 4.5 vs2013

    Description

      Much like -
      From NCBC-306: .NET GetJSON operation throws null reference exception Add support for null values persisted for a key via the CouchbaseClientExtensions.GetJson(…) method. This method will no longer thrown a NullReferenceException when the value store for a key is null and instead simply return null. - See more at: http://www.couchbase.com/communities/comment/1455#comment-1455

      [Test]
      + public void Test_That_GetJson_Supports_Null_Values()
      +

      { + var key = "A_NULL_THING"; + var result = Client.StoreJson(StoreMode.Set, key, null); + Assert.AreEqual(true, result); + + var nullResult = Client.GetJson(key); + Assert.AreEqual(null, nullResult); + }

      I'm not sure this test works for all cases. Say I just started my application can called

      var returnedString = Client.GetJson(key);

      But there isn't anything in the system because I just started up, I'll get a 'System.ArgumentNullException' because:
      public static T GetJson(this ICouchbaseClient client, string key) where T : class

      { var json = client.Get(key); return json == Null ? null : DeserializeObject(key, json); }

      The value 'json' will actually equal null. Since in this test it won't equal the string "Null", it will attempt to call DeserializeObject(key, json), with a null value for 'json'.

      see following test
      [Test]
      public void Test_That_GetJson_Supports_Empty_Values()

      { //ensure key and value are not stored in the system var nullResult = Client.GetJson("my key"); Assert.AreEqual(null, nullResult); //fails }

      Expected behavior
      Just like the standard Client.Get<string>(keyWithNothingInDatabase) returns null, I would expect Client.GetJson(keyWithNothingInDatabase) to also return null.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            jmorris Jeff Morris
            benhysell ben hysell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty