GetJson<T> throwing NullReferenceException
I have been using the Couchbase .NET Client 188.8.131.52 for at while, and the behavior that gave me with the
GetJson<T> method was, that if the key did not exist, it returned
default(T). But after upgrading to 184.108.40.206 I now get a
NullReferenceException, if the key does not exist.
On top of that, I cannot store a simple string value with
StoreJson and fetch it afterwards using
GetJson<string>, as I here get some kind of JSON parsing error.
Can anyone shed light on, what has happened to the previous (and in my opinion, correct) behavior of the JSON extensions?
I haven't tried to reproduce the error and you haven't provided a stack trace, but looking at the source for
GetJson<T> it looks a bit funky.
If this underlying call returns
null, the DocHelper will crash since it tries to access
null.Contains. But the code in line 106, kind off implies that JSON should be able to be null. A bit confusing and I don't know (since I haven't tried it) if it's as simple as not invoking the DocHelper, but since it's an extension method, you could replicate the code your self, right, and see if that solves the issue.
Anyway, I'm sure someone at Couchbase will attend this soon otherwise.
It should be easy to reproduce with an empty Couchbase bucket and a simple call to
GetJson<T>. Version 220.127.116.11, which we are using, returns
default(T), however the new 18.104.22.168 (from NuGet) throws an exception.
Are you able to reproduce this behavior?
There were some changes to dependencies in trying to simplify the client, but to my knowledge there is nothing that should have broken API. Do you have a simple test case by chance that shows the problem without your actual data?