Object reference not set to an instance of an object RiakClient.cs:847
Closed this issue · 6 comments
at CorrugatedIron.RiakClient.ListKeysFromIndex (System.String bucketType, System.String bucket) [0x0001c] in /home/erratic/CorrugatedIron/src/CorrugatedIron/RiakClient.cs:847
on 846:
var result = GetSecondaryIndex(new RiakIndexId(bucketType, bucket, RiakConstants.SystemIndexKeys.RiakBucketIndex), bucket);
I think I'll try calling GetSecondaryIndex and see if I can figure out why thats failing myself
Ok I tried that, now I can't figure out if this error message "unknown_field_type" is because I'm using riak 2 or if theres something wrong with this client or both or what. Using Riak Server 2.0.2 with multi backend, and the latest Corrugated Iron client from the repo
RiakIndexId rid = new RiakIndexId("stream_" + user, "Owner");
var result = client.GetSecondaryIndex(rid, user);
Riak returned an error. Code '0'. Message: Error processing incoming message: error:function_clause:[{riak_api_pb_server,
send_error,
[{unknown_field_type,
<<"owner">>},
{state,
{gen_tcp,inet},
#Port<0.158406>,
undefined,
[{riak_api_basic_pb_service,
undefined},
{riak_core_pb_bucket,
undefined},
{riak_core_pb_bucket_type,
undefined},
{riak_kv_pb_bucket,
{state,
{riak_client,
['riak@127.0.0.1',
undefined]},
undefined,
undefined}},
{riak_kv_pb_counter,
{state,
{riak_client,
['riak@127.0.0.1',
undefined]}}},
{riak_kv_pb_crdt,
{state,
{riak_client,
['riak@127.0.0.1',
undefined]},
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined}},
{riak_kv_pb_csbucket,
{state,
{riak_client,
['riak@127.0.0.1',
undefined]},
undefined,
undefined,
undefined,0}},
{riak_kv_pb_index,
{state,
{riak_client,
['riak@127.0.0.1',
undefined]},
undefined,
undefined,
undefined,0}},
{riak_kv_pb_mapred,
{state,
undefined,
undefined}},
{riak_kv_pb_object,
{state,
{riak_client,
['riak@127.0.0.1',
undefined]},
undefined,
undefined,
<<0,0,0,0>>}},
{yz_pb_admin,
no_state},
{yz_pb_search,
no_state}],
{{127,0,0,1},
58357},
undefined,
undefined,3,
<<0,0,0,35,25,10,
14,115,116,114,
101,97,109,95,
101,114,114,97,
116,105,99,18,5,
79,119,110,101,
114,24,0,34,7,
101,114,114,97,
116,105,99>>,
{buffer,[],0,
1024}}],
[{file,
"src/riak_api_pb_server.erl"},
{line,484}]},
{riak_api_pb_server,
process_message,4,
[{file,
"src/riak_api_pb_server.erl"},
{line,398}]},
{riak_api_pb_server,
connected,2,
[{file,
"src/riak_api_pb_server.erl"},
{line,226}]},
{riak_api_pb_server,
decode_buffer,2,
[{file,
"src/riak_api_pb_server.erl"},
{line,364}]},
{gen_fsm,
handle_msg,7,
[{file,
"gen_fsm.erl"},
{line,505}]},
{proc_lib,
init_p_do_apply,3,
[{file,
"proc_lib.erl"},
{line,239}]}]
any help appreciated
At least that explained that .Value would be null hence that object reference not set to an object
@paigeadele Does this work now that you've fixed your multi backend?
Give me a second and I'll check I was just about to see if I should close this or not
Honestly, as near as I can tell, I'm not having this problem anymore.... but.... @alexmoore @lukebakken after many trials and implementing a logging class/curl generator I was able to determine the following is the correct workflow:
public RiakObject CreateNewUserStreamBucketObject(string id, SessionIdentity si, ZombieletObjectBase zob)
{
var ro = new RiakObject(
SettingsManager.Instance.settings.StreamBucketType,
SettingsManager.Instance.settings.StreamBucketName + "_" + si.UserName,
id,
Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(zob)),
"application/json",
"utf-8");
ro.BinIndex("ObjectType").Add(zob.GetType().ToString());
return ro;
}
public RiakResult<RiakIndexResult> GetObjectsFromStreamBucket(Type t, string username)
{
var streamClient = BackendManager.Instance.GetStreamStore();
var indexResult = streamClient.GetSecondaryIndex(new RiakIndexId(
SettingsManager.Instance.settings.StreamBucketType,
SettingsManager.Instance.settings.StreamBucketName + "_" + username,
"objecttype_bin"), t.ToString());
if(indexResult.IsSuccess)
{
return indexResult;
}
return null;
}
The thing that really bugs me about that is that I had to specify _bin to get it to work.